We need help for regular expression that work with asp.net asp:RegularExpressionValidator to validate date in MMddyy format. Problem we are facing is leap year. Issue is that is it possible to verify through regular expression that it only accepts valid leap year dates like 02/29/2008 is a valid date but 02/29/2010 is not a valid date.
Any regular expression that works with “asp:RegularExpressionValidator”?
OK, you asked for a regex. Here it is. I think it’s immediately obvious why it’s not a good idea to validate a date with a regular expression:
First, the verbose, commented version to at least make understanding this beast possible:
Or, if you can’t use verbose regexes in ASP.NET validators:
These allow but do not require a leading zero in single-digit months/days. If you don’t want that, replace all instances of
0?with0.