Check date in JavaScript
Try this:
if ((myDate.getMonth()+1!=month)||(myDate.getDate()!=day)||(myDate.getFullYear()!=year))
alert("Date Invalid.");
if ((myDate.getDate() != day) ||
(myDate.getMonth() != month - 1) ||
(myDate.getFullYear() != year))
{
return false;
}
JavaScript just converts entered in Date
constructor month
, year
, day
, etc.. in simple int value (milliseconds) and then formats it to represent in string format. You can create new Date(2011, 100, 100)
and everythig will ok :)