EasyUi 日期赋默认值 并且限制选择的日期小于当前日期
2018-01-04 13:42
357 查看
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;
}
<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;
}
相关文章推荐
- EasyUI-datebox设置开始日期小于结束日期,并且结束日期小于当前日期
- easyui datebox日期控制扩展选择日期小于等于当前日期,开始日期小于等于结束日期
- easyui datebox 限制日期选择大小
- EasyUI只可以选择当前日期以前的日期
- 修改easyui日期控件只显示年月,并且只能选择年月
- 梅花雪日历限制只可以小于等于当前日期的功能
- easyui设置datebox默认当前日期,且只能选择当前日期之前的日期
- easyui-datebox限制选择日期范围
- easyui设置datebox默认当前日期,且只能选择当前日期之前的日期
- 在微信小程序中实现时间日期的选择,并且显示当前选择的时间日期
- 修改easyui日期控件只显示年月,并且只能选择年月
- element-ui 限制日期选择的方法(datepicker)
- Easyui datebox单击文本框显示日期选择
- Android DatePicker 限制日期选择范围
- 日期控件限制选择今天以后的日期
- easyui datebox只显示年月选择,隐藏日期
- My97DatePicker两个日期范围不超过30天,第一个小于第二个,都不大于当前日期
- Easyui datebox单击文本框显示日期选择 eayui版本1.5.4.1
- mui自定义日期的起始时间为当前时间,只能选择当前之后的时间
- Mysql日期差函数,Mysql选择两个日期字段相差大于或小于一定时间