What would be regular Expression for validating Date format like mm/yyyy. I am new to regular expressions
$.validator.addMethod(
"customDate",
function(value, element) {
return value.match(?);
},
"Please enter a date in the format mm/yyyy"
);
Can anyone help me in this regard?
Expanding on RobG’s function:
([1-9]|1[0-2])checks it is either1–9or10–12.[12]\d{3}makes sure the year is1or2followed by three numbers (so valid ranges in this case would be1000–2999; if you need more specific values, please update your question.EDIT
If you want month values of 01-12 instead, change the regex to:
/^(0[1-9]|1[0-2])\/[12]\d{3}$/