cbrune
asked on
javascript regex for valid month and day not year
javascript regex for valid month and day not year
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Here is an even simpler test assuming current year.
FIDDLE
FIDDLE
function testDate(dd,mm,yyyy) {
yyyy = yyyy||new Date().getFullYear(); // optional year
mm = mm-1; // JS Months are 0 based
var testDate = new Date(yyyy,mm,dd,12,0,0,0);
window.console&&console.log(testDate); // remove when happy
return dd == testDate.getDate() && mm == testDate.getMonth() && testDate.getFullYear() == yyyy;
}
var dd = 29; // your date
var mm = 2; // your month
window.console&&console.log(testDate(dd,mm));
dd = 32; // your date
mm = 13; // your month
window.console&&console.log(testDate(dd,mm));
dd = 2; // your date
mm = 3; // your month
window.console&&console.log(testDate(dd,mm));
ASKER
I've requested that this question be deleted for the following reason:
2
2
i don't think "2" is a sufficient reason on wanting to delete the question....
ASKER
good answer
https://code.google.com/p/datejs/wiki/APIDocumentation