Copy codeThe Code is as follows:
Var controldate;
Function checkDate (){
Controldate = document. getElementById ("sendDate"). value;
If (controldate = ""){
Alert ('date cannot be null ');
Return false;
} Else {
Var day = new Date (); var Year = 0;
Var Month = 0;
Var Day = 0;
Var CurrentDate = "";
// Initialization time
Year = day. getFullYear ();
Month = day. getMonth () + 1;
Day = day. getDate ();
CurrentDate + = Year + "-";
If (Month> = 10)
{
CurrentDate + = Month + "-";
}
Else
{
CurrentDate + = "0" + Month + "-";
}
If (Day> = 10)
{
CurrentDate + = Day;
}
Else
{
CurrentDate + = "0" + Day;
} // Alert (CurrentDate); // current date
Var startDate = new Date (CurrentDate. replace ("-", ","). getTime ();
Var endDate = new Date (controldate. replace ("-", ","). getTime (); if (startDate> endDate)
{
Alert ('selected date cannot be earlier than the current date! ');
Document. getElementById ("sendDate"). focus ();
Return false;
} Else {
Return true;
}
}
}