function isStartEndDate(startDate,endDate){
//alert(startDate+"==="+endDate);
if(startDate.length>0&&endDate.length>0){
var startDateTemp = startDate.split(" ");
var endDateTemp = endDate.split(" ");
var arrStartDate = startDateTemp[0].split("-");
var arrEndDate = endDateTemp[0].split("-");
var arrStartTime = startDateTemp[1].split(":");
var arrEndTime = endDateTemp[1].split(":");
var allStartDate = new Date(arrStartDate[0],arrStartDate[1],arrStartDate[2],arrStartTime[0],arrStartTime[1],arrStartTime[2]);
var allEndDate = new Date(arrEndDate[0],arrEndDate[1],arrEndDate[2],arrEndTime[0],arrEndTime[1],arrEndTime[2]);
if(allStartDate.getTime()>allEndDate.getTime()){
return false;
}
}
return true;
}
使用:
if(!isStartEndDate(StartDate.value,EndDate.value)){
alert("开始日期不能大于结束日期");
return false;
}
//alert(startDate+"==="+endDate);
if(startDate.length>0&&endDate.length>0){
var startDateTemp = startDate.split(" ");
var endDateTemp = endDate.split(" ");
var arrStartDate = startDateTemp[0].split("-");
var arrEndDate = endDateTemp[0].split("-");
var arrStartTime = startDateTemp[1].split(":");
var arrEndTime = endDateTemp[1].split(":");
var allStartDate = new Date(arrStartDate[0],arrStartDate[1],arrStartDate[2],arrStartTime[0],arrStartTime[1],arrStartTime[2]);
var allEndDate = new Date(arrEndDate[0],arrEndDate[1],arrEndDate[2],arrEndTime[0],arrEndTime[1],arrEndTime[2]);
if(allStartDate.getTime()>allEndDate.getTime()){
return false;
}
}
return true;
}
使用:
if(!isStartEndDate(StartDate.value,EndDate.value)){
alert("开始日期不能大于结束日期");
return false;
}