rtay
asked on
Regulare Expression Validator for date that also allows field to remain blank
I have an optional date field. This field needs to be checked for proper date mm/dd/yyyy or if blank allow the null. This feild can have a date in it, and then the user will null the date out if no longer needed. The validator I use always checks for the date and so does not allow the null.
Thanks for the help
Thanks for the help
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Was this regex supposed to allow the field to be null as well as validate the date?
Yes. It accepts either an empty string or a valid date.
A slightly shorter version : )
^(?:(?:0[1-9]|[12]\d|3[01])/(?:0[1-9]|1[012])/(?:[12]\d{3}))?$
Open in new window