Home > Web Front-end > JS Tutorial > body text

jqGrid date format judgment sample code (start date and end date)_jquery

WBOY
Release: 2016-05-16 17:17:01
Original
1283 people have browsed it

Copy code The code is as follows:

 var beginValue = "开始时间";
                    var endValue = "结束时间";
                    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;
                    }

 

//Verification of date (yyyy-mm-dd)
function CheckDate(strDate, i, dataValue) {
var reg = /^(/d{4})([-])(/ d{2})([-])(/d{2})/;
if (!reg.test(strDate)) {
jAlert("Date format of "i" row "dataValue" Incorrect!/nThe correct format is: 2007-01-01", "prompt information");
                                                                      . 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 year of " dataValue " in row "i" is incorrect, please re-enter!", "Prompt message");
return false;
}
else if (parseInt(year) < 1900 || parseInt(year) > 2100) {
jAlert("The year of "dataValue" in row "i" should be between 1900-2100!", "Prompt message" );
         return false; {
if (isNaN(parseInt(month))) {
jAlert("The month of the "i" row "dataValue" is incorrect, please re-enter!", "Prompt message");
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-12!", "Prompt message");
                                                                                                                                                                                                                                                                   ; month) < 1 || parseInt(month) > 12) {
jAlert("The month of "i" row "dataValue" should be between 1-12!", "Prompt message");
       return false;
  } else {
                 return true; > var daysOfMonth = CalDays(parseInt(year), parseInt(month));
if (isNaN(parseInt(date))) {
jAlert("The date input for the "i"th row "dataValue" is incorrect Please re -enter! "," Note information ");
Return false;
}
Else If (Dateint (Date) & LT; 0 || PARSEINT (Date) & GT; Daysofmonth) {
jAlert("The date of the " i "th" row " dataValue " should be between 1-" daysOfMonth "!", "prompt information"); 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;

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template