data validation

Topics: General, XSLT
Aug 8, 2011 at 6:13 AM

I am trying to add validation to a URL data field.  I created the field called URL and then added a validation field rule.  I used the regex pattern of (http|https|ftp|mailto)://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)? which works, but you can not leave the field blank.  I have the field marked as "optional", but it still requires a valid URL even if I skip the field when creating a new data record.  

I reviewed discussion:  and was successful in using the regex  ^$|https?://.*  (that was shown in the last post) to verify that the HTTP:// or HTTPS:// was included in the url ( and it also let me leave the field blank ).  But I really would want to make sure that the users enters a complete valid URL not just check for the HTTP. 

How can I use the validation and also allow the field to be left blank?  

Thanks in advance of any advice.


Aug 8, 2011 at 6:45 AM


If you read this article  you see that regex pattern ^$ will match empty string, so you can use it like:

^$|(or your URL pathern). The regex should be something like this: ^$|(http|https|ftp|mailto)://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?