easyui设置datebox默认当前日期,且只能选择当前日期之前的日期

来源:互联网 发布:linux中连接本地 编辑:程序博客网 时间:2024/05/20 03:47

引言

全心全意为用户着想是我们的工作准则,所以细节上马虎不得!

场景

当我们进行特定的时间条件选择的时候,会有这样的情况,就是我们只能查询今天以及今天以前的信息,我们可以直接摆上去一个时间控件,但是这样做,会让用户有机会出错,而我们也免不了还要在后面对时间进行验证。所以我们可以再做的完美一点,就是直接对这个时间控件的可选择时间上做点手脚。

jsp

<span class="label">计划运行日期</span>      <input name="planRunDt" 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;          }  });    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;   }  

效果图



阅读全文
0 0
原创粉丝点击