Disabling Prior Dates But Leaving Field Blank?

亡梦爱人 提交于 2019-12-02 09:47:31

Your problem is similar to the one described here: issue #1289.

To solve it just set useCurrent to false. Here a working example:

$("#datetimepicker1").datetimepicker({
  minDate: moment(),  // min date = now
  useCurrent : false, // do not use current date by default
  daysOfWeekDisabled: [5] // disable some weekdays (e.g. fridays)
})
<link href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/css/bootstrap.css" rel="stylesheet"/>
<link href="//cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.42/css/bootstrap-datetimepicker.css" rel="stylesheet"/>

<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.15.2/moment.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/js/bootstrap.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.42/js/bootstrap-datetimepicker.min.js"></script>

<div class="input-group date" id="datetimepicker1">
  <input type="text" class="form-control" />
  <span class="input-group-addon">
    <span class="glyphicon glyphicon-calendar"></span>
  </span>
</div>

What about this hack ? It doesn't allow selecting the previous day but it's still shown as enabled. Not sure if this will help.

("#mydp").datetimepicker({ minDate:(new Date()).setDate(new Date().getDate() - 1),
  useCurrent : false 
})
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!