Due to what I said in the comments ...
Another way to check if the date is correct is to check if the material you passed to the new Date function is passed, like what comes out of it, for example:
// Remember that the month is 0-based so February is actually 1... function isValidDate(year, month, day) { var d = new Date(year, month, day); if (d.getFullYear() == year && d.getMonth() == month && d.getDate() == day) { return true; } return false; }
then you can do this:
if (isValidDate(2013,1,31))
and it will return true if it is valid and false if it is invalid.
source share