CopyCode The Code is as follows: function checkinputdate (OBJ ){
VaR strdate = obj. value;
VaR Re =/^ (\ D {4})-(\ D {2})-(\ D {2}) $ /;
If (Re. Test (strdate) // determines that the date format complies with the YYYY-MM-DD Standard
{
VaR dateelement = new date (Regexp. $1, parseint (Regexp. $2, 10)-1, Regexp. $3 );
If (! (Dateelement. getfullyear () = parseint (Regexp. $1) & (dateelement. getmonth () + 1) = parseint (Regexp. $2, 10) & (dateelement. getdate () = parseint (Regexp. $3) // judge the date Logic
{
Document. getelementbyid ("errormessage"). innertext = "You can only input date. (YYYY-MM-DD )! ";
Document. getelementbyid ("error"). style. Display = "";
OBJ. value = '';
}
} Else {
Document. getelementbyid ("errormessage"). innertext = "You can only input date. (YYYY-MM-DD )! ";
Document. getelementbyid ("error"). style. Display = "";
OBJ. value = '';
}
}