I want to validate card expiration date on format MM/YY
, MM
should have values from 01
to 12
and YY
from 19
to 99
.
This is my code:
^(0[1-9]|10|11|12)/1[9]|2[0-9]{2}$
The MM
part seems to work fine but the YY
doesn't. It only take 19
as valid but also if I add new digits after that it says it's valid.
I was expecting to not validate if there are more than 2 digits for YY
because of {2}
.
How should it be changed in order to validate all years from 19
to 99
?