defaultDate and minDate with Bootstrap Datetimepicker

别来无恙 提交于 2019-12-05 10:07:16

Looking at the code on GitHub (line 1674) if you set the option useCurrent to false, your default may not be overridden:

 <script type="text/javascript">
   $(function () {
     $('#enddatepicker').datetimepicker({
       useCurrent: false,
       minDate: moment().add(1, 'd').toDate(),
       defaultDate: moment().add(1, 'M').toDate(),
       locale: 'de',
       format: 'DD.MM.YYYY'
     });
   });
 </script>

I would raise an issue in github for this, as minDate should not override defaultDate. In the mean-time, all you can do is set the value explicitly:

$(function () {
    $('#enddatepicker').datetimepicker({
         minDate: moment().add(1, 'd').toDate(),
         locale: 'de',
         format: 'DD.MM.YYYY'
    });
     $('#enddatepicker').val(moment().add(1, 'M').format('DD.MM.YYYY'));
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.9.0/moment-with-locales.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<script src="https://cdn.rawgit.com/Eonasdan/bootstrap-datetimepicker/e8bddc60e73c1ec2475f827be36e1957af72e2ea/src/js/bootstrap-datetimepicker.js"></script>
<link href="https://cdn.rawgit.com/Eonasdan/bootstrap-datetimepicker/e8bddc60e73c1ec2475f827be36e1957af72e2ea/build/css/bootstrap-datetimepicker.css" rel="stylesheet"/>

<div class="container">
  <div class="row">
    <div class="demo col-xs-6">
       <input class="form-control" id="enddatepicker"/>
    </div>
  </div>
</div>

Try with Start Date property, after checked my jquery i found that has not minDate parameter but startDate parameter to handle minDate.it will work for you.

startDate :new Date(),

skype @lokesh7676 to get more help

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!