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;
}
Validation of dates (YYYY-MM-DD)
function Checkdate (strdate, I, DataValue) {
var reg =/^ (/d{4}) ([-]) (/d{2}) ([-]) (/d{2})/;
if (!reg.test (strdate)) {
Jalert ("First" + i + "line" +datavalue+ "date format is incorrect!/n correct 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 judgment
Function Checkyear (year, I,datavalue) {
if (isNaN (parseint (year)) {
Jalert ("The first" + i + "line" +datavalue+ "the year entered incorrectly, please re-enter!", "prompt Information");
return false;
}
else if (parseint) < 1900 | | parseint (YEAR) > 2100) {
Jalert ("First" + i + "line" + DataValue + "Year should be between 1900-2100!", "hint info");
return false;
}
else {
return true;
}
}
Month Judgment
function checkmonth (month, I, DataValue) {
if (isNaN (parseint (month)) {
Jalert ("the" "+ i +" line "+datavalue+" the month input is incorrect, please re-enter! "," prompt Information ");
return false;
}
if (month.substring (0, 1) = = 0) {
if (parseint (month.substring (1, 2)) < 1) {
The month of Jalert ("the first" + i + "line" +datavalue+ "should be between 1-12!", "prompt Information");
return false;
}
}
else if (parseint (month) < 1 | | | parseint (MONTH) > 12) {
The month of Jalert ("the first" + i + "line" +datavalue+ "should be between 1-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 ("the" "+ i +" line "+datavalue+" date entered incorrectly, please re-enter! "," prompt Information ");
return false;
}
else if (parseint (date) < 0 | | parseint (DATE) > Daysofmonth) {
Jalert ("First" + i + "line" +datavalue+ "date should be in 1-" + Daysofmonth + "between!", "hint info");
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 && Year% 100!= 0) | | (Year% 400 = 0)) {
return true;
} else {
return false;
}
}