Link to home
Create AccountLog in
Avatar of Charles Baldo
Charles BaldoFlag for United States of America

asked on

Need regex for proper date

I have this expression in a  <asp:RegularExpressionValidator control
(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d

It has a problem with the date. It will allow any day in any month up to the 31.  Is there a regex for a "Valid Date" format  I need it in mm/dd/yyyy format.

Leap year would be super great to catch

Thanks
chuck
SOLUTION
Avatar of HonorGod
HonorGod
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
ASKER CERTIFIED SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Avatar of Charles Baldo

ASKER

I used ideas from both the regex validated a date nice. With a proper format date I could format without fear of it being a bad date.  Thanks Both
Thanks for the assist, and the points.

Good luck & have a great day.