easyUI日期框的日期范围限制

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/sunhongbing1024/article/details/73033290
使用eayUI日期框的日期范围限制
对应的官网页面: http://www.jeasyui.net/demo/345.html
案例1:控制只能选择本月份的(6.1号-6.30号)

<input type="text" class="easyui-datebox appCheckDate" id="checkDate" data-options="required:true" name="checkDate" editable="false">


//控制时间的显示范围
$('.appCheckDate').datebox().datebox('calendar').calendar({
validator: function(date){
var now = new Date();
var curMonth=now.getMonth()+1;
var d1 = new Date(now.getFullYear(), now.getMonth(), 1);
var d2;
//用于判断一年中31天的月份
var arr = [ 1,3,5,7,8,10,12 ];
if($.inArray(curMonth, arr)==0){
d2 = new Date(now.getFullYear(), now.getMonth(),31);
}else if(curMonth==2){//二月份特殊处理
d2 = new Date(now.getFullYear(), now.getMonth(),28);
}else{//其他月份为30天
d2 = new Date(now.getFullYear(), now.getMonth(),30);
}
return d1<=date && date<=d2; //控制范围
}
});




猜你喜欢

转载自blog.csdn.net/sunhongbing1024/article/details/73033290