欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

jqGrid日期格式的判斷示例代碼(開始日期與結(jié)束日期)

 更新時(shí)間:2013年11月08日 09:29:26   作者:  
jqGrid日期格式的判斷示例代碼(開始日期與結(jié)束日期)。需要的朋友可以過來參考下,希望對(duì)大家有所幫助

復(fù)制代碼 代碼如下:

 var beginValue = "開始時(shí)間";
                    var endValue = "結(jié)束時(shí)間";
                    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;
                    }

 

//日期的驗(yàn)證(yyyy-mm-dd)
function CheckDate(strDate, i, dataValue) { 
    var reg = /^(/d{4})([-])(/d{2})([-])(/d{2})/;
    if (!reg.test(strDate)) {
        jAlert("第" + i + "行"+dataValue+"的日期格式不正確!/n正確格式為:2007-01-01", "提示信息");
        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;
}
//年份判斷
function checkYear(year, i,dataValue) {
    if (isNaN(parseInt(year))) {
        jAlert("第" + i + "行"+dataValue+"的年份輸入有誤,請(qǐng)重新輸入!", "提示信息");
        return false;
    }
    else if (parseInt(year) < 1900 || parseInt(year) > 2100) {
        jAlert("第" + i + "行" + dataValue + "的年份應(yīng)該在1900-2100之間!", "提示信息");
        return false;
    }
    else {
        return true;
    }
}
//月份判斷
function checkMonth(month, i, dataValue) {
    if (isNaN(parseInt(month))) {
        jAlert("第" + i + "行"+dataValue+"的月份輸入有誤,請(qǐng)重新輸入!", "提示信息");
        return false;
    }
    if (month.substring(0, 1) == 0) {
        if (parseInt(month.substring(1, 2)) < 1) {
            jAlert("第" + i + "行"+dataValue+"的月份應(yīng)該在1-12之間!", "提示信息");
            return false;
        }
    }
    else if (parseInt(month) < 1 || parseInt(month) > 12) {
        jAlert("第" + i + "行"+dataValue+"的月份應(yīng)該在1-12之間!", "提示信息");
        return false;
    } else {
        return true;
    }
}
//日期判斷
function checkDate(year, month, date, i,dataValue) {
    var daysOfMonth = CalDays(parseInt(year), parseInt(month));
    if (isNaN(parseInt(date))) {
        jAlert("第" + i + "行"+dataValue+"的日期輸入有誤,請(qǐng)重新輸入!", "提示信息");
        return false;
    }
    else if (parseInt(date) < 0 || parseInt(date) > daysOfMonth) {
        jAlert("第" + i + "行"+dataValue+"的日期應(yīng)該在1-" + daysOfMonth + "之間!", "提示信息");
        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;
    }
}

相關(guān)文章

最新評(píng)論