Reputation: 196
I need a regular expression for for MM/yyyy. I need to validate only month and year and enforce the user to just enter date like 01/1999 etc...
Upvotes: 1
Views: 223
Reputation: 15945
^(0[1-9]|1[0-2])/\d{4}$
Note that this only checks for month. One can enter years like 0000 or 9999. The check for this can be implemented with a few regex constructs, depending on your constraints.
Upvotes: 4