Click here to Skip to main content
15,885,365 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
I wanted to validate a date, so i change the the textbox mode from "single" to "date" in asp.net 2012 it worked wonderful in chrome, however, it did not work in IE and firefox.

to make sure that a valid date is entered in IE, firefox and other browsers I added

ASP.NET
<asp:RegularExpressionValidator ID="dateValRegex" runat="server" ControlToValidate="TxtDOB" ErrorMessage="Please Enter a valid date in the format (mm/dd/yyyy)" ValidationExpression="^(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d$"></asp:RegularExpressionValidator>


it worked fine in IE, and Firefox when entering the date however when I enter a valid date in chrome I am getting the validation error message.

is there are validation for all browsers?

What I have tried:

<asp:RegularExpressionValidator ID="dateValRegex" runat="server" ControlToValidate="TxtDOB" ErrorMessage="Please Enter a valid date in the format (mm/dd/yyyy)" ValidationExpression="^(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d$">
Posted
Comments
Member 9331278 9-Mar-16 14:08pm    
Also the same thing in chrome happens in Edge the validation error message is displayed and will not move even when a valid date is entered
Wonde Tadesse 9-Mar-16 21:06pm    
Just curious. Why don't you use data picker like https://jqueryui.com/datepicker/
Sinisa Hajnal 10-Mar-16 2:40am    
Old IE doesn't support input type date, this is HTML 5 I believe. Valid date depends on your browser culture settings. Try entering 31.12.2000 to see if it is valid (it would be in most world countries) - but remove your regex first.
Member 9331278 10-Mar-16 7:16am    
no 31. 12.2000 invalid date message

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900