Reputation: 25270
What is the regular expression for validating a month with the leading zero?
Passes regular expression:
01,02,03,04,05,06,07,08,09,10,11,12
Fails regular expression:
1, 00, 13 and up.
Upvotes: 4
Views: 9377
Reputation: 23
I think this is a better one, it accepts '05', but also '5' as a month:
/(^0?[1-9]$)|(^1[0-2]$)/
Upvotes: 2