easyui datebox 开始/结束时间 动态互相限制
前端  /  管理员 发布于 5年前   816
easyui这个就不多说了,两种方式;话不多说直接上代码;
前端代码:
开始: <input id="start" type="text" name="startdate" class="easyui-datebox"> 结束: <input id="end" type="text" name="enddate" class="easyui-datebox">
js代码:
1.动态限制结束时间 //##时间限制 start ##// //开始日期选择时触发 $('#<?php echo NS;?>start').datebox({ onSelect : function(){ //启用结束日期控件 $('#<?php echo NS; ?>end').datebox('enable'); setTimeout(function () { var start = $('#<?php echo NS; ?>start').datebox('getValue'); var end = $('#<?php echo NS; ?>end').datebox('getValue'); //开始日期大于结束日期 重置结束日期 if (start > end) { $('#<?php echo NS; ?>end').datebox('reset'); } },200); } }); $(function(){ //开始日期选今天之前 $('#<?php echo NS; ?>start').datebox().datebox('calendar').calendar({ validator: function(date){ var now = new Date(); var d1 = new Date(now.getFullYear(), now.getMonth(), now.getDate()); return d1>=date; } }); //选择开始日期之后 $('#<?php echo NS; ?>end').datebox().datebox('calendar').calendar({ validator: function(date){ var now = new Date(); var d1 = new Date(now.getFullYear(), now.getMonth(), now.getDate()); var d2 = $('#<?php echo NS; ?>start').datebox('getValue'); var d2 = new Date(Date.parse(d2.replace(/-/g,"/"))); return d1<=date || date>=d2; } }); }); //##时间限制 end ##// 2.动态互相限制 //##时间限制 start ##// $(function() { //开始日期选结束日期之前 $('#<?php echo NS; ?>start').datebox( { onShowPanel: function () { $(this) .datebox('calendar') .calendar({ validator: function (date) { var end = $('#<?php echo NS; ?>end').datebox('getValue'); if (end) { end = new Date(Date.parse(end.replace(/-/g, "/"))); } else { end = new Date(); } return date <= end; } }) } }); //结束日期选开始日期之后 $('#<?php echo NS; ?>end').datebox( { onShowPanel: function () { $(this) .datebox('calendar') .calendar({ validator: function (date) { var start = $('#<?php echo NS; ?>start').datebox('getValue'); if (start) { start = new Date(Date.parse(start.replace(/-/g, "/"))); } else { start = new Date(); } return date >= start; } }) } }); }) //##时间限制 end ##//
效果就不截图了 有兴趣的自己测试哦
路人 在
php中使用hyperf框架调用讯飞星火大模型实现国内版chatgpt功能示例中评论 教程很详细,如果加个前端chatgpt对话页面就完美了..博主 在
科学上网翻墙之v2rayN-Core客户端免费公益节点使用教程中评论 @ mashrdn 多切换几个节点测试,免费ssr是没那么稳..mashrdn 在
科学上网翻墙之v2rayN-Core客户端免费公益节点使用教程中评论 V2rayn免费节点添加上去了,youtobe无法打开网页,是怎么回事..张伟 在
科学上网翻墙之v2rayN-Core客户端免费公益节点使用教程中评论 3q!有用,不过免费节点隔天就要去git上复制新的导进去..博主 在
科学上网翻墙访问Google , 上外网神器佛跳墙VPN(永久免费)使用流程步骤中评论 该篇教程已不能用了,告知大家,免的老有老铁问我!..
Copyright·© 2019 侯体宗版权所有·
粤ICP备20027696号