Determine whether the start time is earlier than the end time on the js front end. If you need jquery, refer
The Code is as follows:
// Determine whether the start time is earlier than the end time
If ($ ("# txtBeginTime"). length> 0 & $ ("# txtEndTime"). length> 0 ){
If (Date. parse (TimeFormatToSQL ($ ("# txtBeginTime "). val ()). replace ("-", "/")> Date. parse (TimeFormatToSQL ($ ("# txtEndTime "). val ()). replace ("-","/"))){
Alert ("the start time cannot be later than the end time! ");
// $ ("# TxtBeginSearchTimeByBE"). focus ();
Return;
///
/// Convert the passed time value to the time format recognized by SQL
///Time (normal page display time format)
///
Function TimeFormatToSQL (strTime ){
Var strResult = "";
Var strTemp = "";
For (var I = 0; I <strTime. length; I ++ ){
StrTemp = strTime. substr (I, 1 );
If (strTemp = "year" | strTemp = "month ")
StrResult + = "-";
Else
If (strTemp = "day" | strTemp = "second "){
If (strTemp = "day ")
StrResult + = "| ";
Else
StrResult + = "";
}
Else
If (strTemp = "Hour" | strTemp = "Minute ")
StrResult + = ":";
Else
StrResult + = strTemp;
}
Var strArgDateTime = strResult. split ('|'); // The time format may be 2010-11-11 11: Or 2010-11-11 11.
If (strArgDateTime. length = 1 ){
// Process the date part
Var strArgDate = strArgDateTime [0]. split ('-'); // process the time part, which may be in the format of 11: 11 or.
If (strArgDate. length = 2 ){
If (strArgDate [1]. length <1)
StrResult = strArgDate [0];
Else
StrResult = strArgDateTime [0] + "-01 ";
} Else
If (strArgDate. length = 3 ){
If (strArgDate [2]. length <1)
StrResult = strArgDate [0] + "-" + strArgDate [1] + "-01 ";
}
}
Else
If (strArgDateTime. length = 2 ){
// Process the time part
Var strArgTime = strArgDateTime [1]. split (':'); // process the time part, which may be in the format of 11: 11 or.
If (strArgTime. length = 1 ){
StrResult = strArgDateTime [0] + "" + strArgDateTime [1] + ": 00: 00"
} Else
If (strArgTime. length = 2 ){
If (strArgTime [1]. length <1)
StrResult = strArgDateTime [0] + "" + strArgDateTime [1] + "00"
Else
StrResult = strArgDateTime [0] + "" + strArgDateTime [1] + ": 00"
} Else
If (strArgTime. length = 3 ){
If (strArgTime [2]. length <1)
StrResult = strArgDateTime [0] + "" + strArgDateTime [1] + "00"
}
}
Return strResult;
}