//年月日期有效性检验 function yearAndMonthCheck() { var flag = true; var currentyear = new Date().getFullYear(); var currentmonth = new Date().getMonth(); var yearvalue = $("#fsyear").val(); var monthvalue = $("#fsmonth").val(); if(yearvalue.length<4) { alert("所输入年限不能小于4位数字"); flag = false; } if((yearvalue !=null && yearvalue!="") || (monthvalue != null && monthvalue !="")) { var stepyear = parseInt(yearvalue) - currentyear; var stepmonth = parseInt(currentmonth) - monthvalue; if(stepyear > 0) { alert("输入年限不能大于本年"); flag = false; } if(stepmonth >12) { alert("月份不能大于12"); flag = false; } //if(stepmonth > 0) //{ // alert("输入年限不能大于本月"); // flag = false; //} } return flag; }