Varshini S
asked on
Regular Expression not working
i am using following regular expression validator, but it not working with the date 19-Feb-2013
it is saying invalid date ? But it is validating 19-Feb-2012. Why this issue ? How do i solve ?
/((([0][1-9]|[12][\d])|[3] [01])[-\/] ((Jan|Mar| May|Jul|Au g|Oct|Dec) )[-\/][1-9 ]\d\d\d)|( (([0][1-9] |[12][\d]) |[3][0])[- \/]((Jan|M ar|Apr|May |Jun|Jul|A ug|Sep|Oct |Nov|Dec)) [-\/][1-9] \d\d\d)|(( [0][1-9]|[ 12][\d])[- \/]((Feb)) [-\/][1-9] \d([02468] [048]|[135 79][26]))| (([0][1-9] |[12][0-8] )[-\/]((Fe b))[-\/][1 -9]\d\d\d) /i
it is saying invalid date ? But it is validating 19-Feb-2012. Why this issue ? How do i solve ?
/((([0][1-9]|[12][\d])|[3]
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
www.regexlib.com
has regular expressions for almost anything. There is one on there that does exactly what you want. Look under Date/Time.
Cheers.
has regular expressions for almost anything. There is one on there that does exactly what you want. Look under Date/Time.
Cheers.
Why use a regex for date validation? Why not use a CompareValidator?
e.g. (http://stackoverflow.com/a/939852/884561)
e.g. (http://stackoverflow.com/a/939852/884561)
<asp:CompareValidator
id="dateValidator" runat="server"
Type="Date"
Operator="DataTypeCheck"
ControlToValidate="txtDatecompleted"
ErrorMessage="Please enter a valid date.">
</asp:CompareValidator>
ASKER