I have the following regular expression to validate the date in ‘mm/dd/yyyy’ format. It works for ’12/11/2006′. But if I use ‘2/3/2011′, it doesn’t work. Could you please correct the following expression to accept ’12/11/2006’ or ‘2/3/2011’ format? Thank you for help.
var date = /(0[1-9]|1[012])[- \/.](0[1-9]|[12][0-9]|3[01])[- \/.](19|20)\d\d/;
Just make the
0optional:0?