Valid date format

User 39859 Photo


Registered User
62 posts

I need to require a valid date of birth in the format mm/dd/yyyy. I am having difficulty getting it right with the regular expression. I can get it close, i.e., it requires numbers in that format, but, I can enter a date that isn't valid, like, a time paradox where I am born in the future. :D

I need to make sure that the dob is at least not something in the future, like 2018 for the year, or wrong, like 22 for the month, etc.

I've been able to make regular expression fields for phone and social security, but this one is not working for me.

I would appreciate suggestions.

Thanks.
User 38401 Photo


Senior Advisor
10,951 posts

I don't know much on Reg. Expressions as of yet, but have you tried the really simple way and just create drop down boxes for the dates? One for the month, one for the day and one for the year and just include the years you need them to be? The years may be a bit tedious, but after that all you need to do is adjust your form once a year to include another year and that's it. You can make each of the drop downs required to be sure they get filled in too. Just a thought.
User 39859 Photo


Registered User
62 posts

Well, I guess I am trying to make it more difficult than it needs to be. Thank you that is an excellent suggestion, and an easy way to make sure that the person who applies at least indicates they are 18 years of age.

If anyone knows how to do it with the regex I would still be curious, but, the drop-downs will work just fine.

Thanks.

Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.