I need help coming up with a regex to make sure the user enters a valid date
The string will be in the format of mm/dd/yyyy
Here is what I have come up with so far.
/\[1-9]|0[1-9]|1[0-2]\/\d{1,2}\/19|20\d\d/
I have validated the regex where the user cannot enter a day higher than 12 and the years have to start with either “19” or “20”. What I am having trouble is figuring out some logic for validating the day. The day should not go over 31.
Regex for 0-31:
Or if you don’t want days with a preceding zero (e.g. 05):