0

I have a RegularExpressionValidator in my ASP.Net page

I am using it for checking the valid date including leap year against the TextBox Control.

The code is:

<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"   
ErrorMessage="Enter Valid Date" Display="Dynamic" Font-Bold="true" ForeColor="Red" 
ValidationExpression=
"^(((0[1-9]|[12]\d|3[01])(-|\/)(0[13578]|1[02])(-|\/)((19|[2-9]\d)\d{2}))|((0

[1-9]|[12]\d|30)(-|\/)(0[13456789]|1[012])(-|\/)((19|[2-9]\d)\d{2}))|((0[1-9]|1      
\d|2[0-8])(-|\/)02(-|\/)

((19|[2-9]\d)\d{2}))|(29(-|\/)02(-|\/)((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579]
[26])|   ((16|[2468]

[048]|[3579][26])00))))$" ControlToValidate="txtbdate">  
</asp:RegularExpressionValidator>

All dates are checked fine but the date : 09-09-2000 cannot be checked..

Please help..

Thanks in advance.

Mohemmad K
  • 809
  • 7
  • 33
  • 74

1 Answers1

0

The second 'line' will match that.

I suspect it is all those newlines in the regex causing the issue.

((0[1-9]|[12]\d|30)(-|\/)(0[13456789]|1[012])(-|\/)((19|[2-9]\d)\d{2}))

You can test it here: http://regexpal.com/

Works fine for me.

leppie
  • 115,091
  • 17
  • 196
  • 297