Copy codeThe Code is as follows:
Var beginValue = "Start Time ";
Var endValue = "End Time ";
Var dispaly = jQuery ("# testSubjectGrid"). jqGrid ("getCell", idArray [I], "display_content ");
If (CheckDate (begindata, dispaly, beginValue) = false ){
Return false;
}
If (CheckDate (enddata, dispaly, endValue) = false ){
Return false;
}
// Verify the date (yyyy-mm-dd)
Function CheckDate (strDate, I, dataValue ){
Var reg =/^ (/d {4}) ([-]) (/d {2}) ([-]) (/d {2 })/;
If (! Reg. test (strDate )){
JAlert ("the" + I + "row" + dataValue + "date format is incorrect! /N format: 2007-01-01 "," prompt information ");
Return false;
}
Var ss = strDate. split ("-");
Var year = ss [0];
Var month = ss [1];
Var date = ss [2];
If (! CheckYear (year, I )){
Return false;
}
If (! CheckMonth (month, I, dataValue )){
Return false;
}
If (! CheckDate (year, month, date, I, dataValue )){
Return false;
}
Return true;
}
// Year determination
Function checkYear (year, I, dataValue ){
If (isNaN (parseInt (year ))){
The year of jAlert ("+ I +" row "+ dataValue +" is incorrect. Please enter it again! "," Prompt information ");
Return false;
}
Else if (parseInt (year) <1900 | parseInt (year)> 2100 ){
JAlert (the year of "+ I +" row "+ dataValue +" should be! "," Prompt information ");
Return false;
}
Else {
Return true;
}
}
// Month judgment
Function checkMonth (month, I, dataValue ){
If (isNaN (parseInt (month ))){
JAlert ("+ I +" row "+ dataValue +" Incorrect month input. Please enter it again! "," Prompt information ");
Return false;
}
If (month. substring (0, 1) = 0 ){
If (parseInt (month. substring (1, 2) <1 ){
JAlert (the month of "+ I +" row "+ dataValue +" should be between 1 and 12! "," Prompt information ");
Return false;
}
}
Else if (parseInt (month) <1 | parseInt (month)> 12 ){
JAlert (the month of "+ I +" row "+ dataValue +" should be between 1 and 12! "," Prompt information ");
Return false;
} Else {
Return true;
}
}
// Date judgment
Function checkDate (year, month, date, I, dataValue ){
Var daysOfMonth = CalDays (parseInt (year), parseInt (month ));
If (isNaN (parseInt (date ))){
JAlert ("+ I +" row "+ dataValue +" Date input is incorrect. Please enter it again! "," Prompt information ");
Return false;
}
Else if (parseInt (date) <0 | parseInt (date)> daysOfMonth ){
JAlert ("the" + I + "row" + dataValue + "date should be between 1-" + daysOfMonth +! "," Prompt information ");
Return false;
}
Else {
Return true;
}
}
Function CalDays (year, month ){
Var date = new Date (year, month, 0 );
Return date. getDate ();
}
Function isLeapYear (year ){
If (year % 4 = 0 & amp; year % 100! = 0) | (year % 400 = 0 )){
Return true;
} Else {
Return false;
}
}