function compareDate(checkStartDate, checkEndDate) {
var arys1= new Array();
var arys2= new Array();
var arys3= new Array();
var d = new Date();
var str = d.getFullYear()+"-"+((d.getMonth()+1)>=10?+(d.getMonth()+1):"0"+(d.getMonth()+1))+"-"+((d.getDate())>=10?d.getDate():'0'+d.getDate());
arys3=str.split('-');
var nowdate=new Date(arys3[0],parseInt(arys3[1]-1),arys3[2]);
if(checkStartDate != null && checkStartDate != "") {
arys1=checkStartDate.split('-');
var sdate=new Date(arys1[0],parseInt(arys1[1]-1),arys1[2]);
if(sdate < nowdate){
if(checkEndDate == null && checkEndDate == ""){
checkEndDate = str;
arys2=checkEndDate.split('-');
var edate=new Date(arys2[0],parseInt(arys2[1]-1),arys2[2]);
return true;
}else{
arys2=checkEndDate.split('-');
var edate=new Date(arys2[0],parseInt(arys2[1]-1),arys2[2]);
if(edate <= nowdate && edate > sdate){
return true;
}else{
parent.alertBox.showAlert("结束日期不在查询范围内!",'warning');
return false;
}
}
}else{
parent.alertBox.showAlert("开始日期不能大于当前日期!",'warning');
return false;
}
}else{
if(checkEndDate != null && checkEndDate != ""){
parent.alertBox.showAlert("请填写开始日期!",'warning');
return false;
}else{
return true;
}
}
}
调用:
var a = $('#queryBegaintime').datebox('getValue');
var b = $('#queryEndtime').datebox('getValue');
var d = compareDate(a,b);
if(d){
parameter['begintime'] = a;
parameter['endtime'] = b;
}