该功能适用于1.3.6版本以上,请注意你项目的版本号
<input name="createtime_d" id="createtime" class="easyui-datebox" data-options="width:90,formatter:myformatter,parser:myparser"> -- <input name="createtime_d" id="endTime"
class="easyui-datebox" data-options="width:90,formatter:myformatter,parser:myparser">
<script>
<%--限制日期范围--%>
$('#endTime').datebox().datebox('calendar').calendar({
validator: function(date){
var now = new Date();
var d1 = new Date(now.getFullYear(), now.getMonth(), now.getDate());
return d1>=date;
}
});
function myformatter(date){
var y = date.getFullYear();
var m = date.getMonth()+1;
var d = date.getDate();
return y+'-'+(m<10?('0'+m):m);
}
function myparser(s){
if (!s) return new Date();
var ss = (s.split('-'));
var y = parseInt(ss[0],10);
var m = parseInt(ss[1],10);
var d = parseInt(ss[2],10);
if (!isNaN(y) && !isNaN(m) && !isNaN(d)){
return new Date(y,m-1,d);
} else {
return new Date();
}
}
</script>