function checkDate(obj){ var strDate = obj.value; var nowDate = new Date(); var a=/^(d{1,4})(-|/)(d{1,2})2(d{1,2})/ if (!a.test(strDate)){ alert("日期格式不正确,格式应为yyyy-mm-ss!") obj.value = formatDate(nowDate); return false; } var arr=strDate.split("-"); var starttime=new Date(arr[0],arr[1],arr[2]); var starttimes=starttime.getTime(); var nowtimes=nowDate.getTime(); if(starttimes < nowtimes){ alert("截止日期不能小于系统当前日期!"); obj.value = formatDate(nowDate); return false; } return true; } function formatDate(strTime) { var date = new Date(strTime); return date.getFullYear()+"-"+(date.getMonth()+1)+"-"+date.getDate(); }