HTML代码
<input name="" id="planRunDt" class="easyui-datebox" data-options="editable:false">
JS代码:
$('#planRunDt').datebox('setValue', getCurentDateStr()); //赋默认值为当前日期
$('#planRunDt').datebox('calendar').calendar({ //设置日期小于当前日期
validator : function(date){
var now = new Date();
var d1 = new Date(now.getFullYear(),now.getMonth(),now.getDate());
return date <= d1;
}
});
$('#start').datebox({//当选择开始日期时,给结束日期增加验证大于开始日期
onSelect: function(date){
$('#end').datebox('calendar').calendar({
validator : function(date1){
var d1 = new Date(date.getFullYear(),date.getMonth(),date.getDate());
return date1 >= d1;
}
});
}
});
function getCurentDateStr() {
var now = new Date();
var year = now.getFullYear(); //年
var month = now.getMonth() + 1; //月
var day = now.getDate(); //日
var clock = year + "-";
if(month < 10) clock += "0";
clock += month + "-";
if(day < 10) clock += "0";
clock += day;
return clock;
}