In web development, you sometimes need to compare the time (mainly the start time and end time) in the input box. After searching on the Internet, it is found that many of them are invalid, the following methods have been verified by the younger brother. In web development, you sometimes need to compare the time (mainly the start time and end time) in the input box. After searching on the Internet, it is found that many of them are invalid, the following methods have been verified by the younger brother. (Please pay attention to the red part)
Function ValidtorTime (){
Var d1 = new Date (document. getElementById ('txbfromdate ') . Value. replace (/\-/g ,"\/"));
Var d2 = new Date (document. getElementById ('txbtodate ') . Value. replace (/\-/g ,"\/"));
If (d1> d2)
{
Alert ("the end time must be after the start time! ");
Return false;
}
Return true;
}