function isMMDD(value) {
var re = /^([0]?[1-9]|1[0-2])\/([0-2]?[0-9]|3[0-1])$/;
if (re.test(value)) {
return true;
}
else
return false;
}
I would like to have 02/30 as invalid too.
function isMMDD(value) {
var re = /^([0]?[1-9]|1[0-2])\/([0-2]?[0-9]|3[0-1])$/;
if (re.test(value)) {
return true;
}
else
return false;
}
I would like to have 02/30 as invalid too.
With information in here
If you are validating the user's input of a date in a script, it is probably easier to do certain checks outside of the regex. For example, excluding February 29th when the year is not a leap year is far easier to do in a scripting language. It is far easier to check if a year is divisible by 4 (and not divisible by 100 unless divisible by 400) using simple arithmetic than using regular expressions.
In your case it applies the same thing, also it is a very asked question.