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
Charles BaldoSoftware DeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

HonorGodSoftware EngineerCommented:
It is much safer to have a simple RegExp (like the one you have), and then use the match to create a date object.  This date object can be formatted to match the input, and then these 2 values can be compared.

0
wdosanjosCommented:
Please check the regular expression on the link below created by Dany Lauener.

MM/dd/yyyy with 100% leap years. Valid since year 1900. MM and DD could have 1 or 2 digits : M/d/yyyy or MM/d/yyyy or M/dd/yyyy

http://www.regxlib.com/REDetails.aspx?regexp_id=1071
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Charles BaldoSoftware DeveloperAuthor Commented:
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
0
HonorGodSoftware EngineerCommented:
Thanks for the assist, and the points.

Good luck & have a great day.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Regular Expressions

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.