bootstrap datetimepicker 阻止打印 minDate
bootstrap datetimepicker prevent minDate from printing
我正在使用 bootstrap datetimepicker,这是我的脚本
$('.start_datetime, .end_datetime').datetimepicker({
format: 'YYYY-MM-DD HH:mm:ss',
inline:false,
ignoreReadonly: true,
allowInputToggle: true,
sideBySide:true,
minDate: new Date()
});
在上面的脚本中,我将 minDate
初始化为今天的日期,但问题是当我检查结果时,今天的日期已经作为文本框的打印值出现,但我不想打印它我希望它只是限制它选择早于今天的日期。
选择器显示今天的日期,因为默认情况下 useCurrent
选项是 true
,如 documentation.
中所述
将useCurrent
设置为false
即可解决您的问题,如下代码所示:
$('.start_datetime, .end_datetime').datetimepicker({
format: 'YYYY-MM-DD HH:mm:ss',
inline: false,
ignoreReadonly: true,
allowInputToggle: true,
sideBySide:true,
minDate: new Date(),
useCurrent: false
});
<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.37/css/bootstrap-datetimepicker.css" rel="stylesheet"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.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.13.0/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.37/js/bootstrap-datetimepicker.min.js"></script>
<div class="form-group">
<div class="input-group date start_datetime">
<input type="text" class="form-control" />
<span class="input-group-addon"><span class="glyphicon-calendar glyphicon"></span></span>
</div>
</div>
我正在使用 bootstrap datetimepicker,这是我的脚本
$('.start_datetime, .end_datetime').datetimepicker({
format: 'YYYY-MM-DD HH:mm:ss',
inline:false,
ignoreReadonly: true,
allowInputToggle: true,
sideBySide:true,
minDate: new Date()
});
在上面的脚本中,我将 minDate
初始化为今天的日期,但问题是当我检查结果时,今天的日期已经作为文本框的打印值出现,但我不想打印它我希望它只是限制它选择早于今天的日期。
选择器显示今天的日期,因为默认情况下 useCurrent
选项是 true
,如 documentation.
将useCurrent
设置为false
即可解决您的问题,如下代码所示:
$('.start_datetime, .end_datetime').datetimepicker({
format: 'YYYY-MM-DD HH:mm:ss',
inline: false,
ignoreReadonly: true,
allowInputToggle: true,
sideBySide:true,
minDate: new Date(),
useCurrent: false
});
<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.37/css/bootstrap-datetimepicker.css" rel="stylesheet"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.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.13.0/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.37/js/bootstrap-datetimepicker.min.js"></script>
<div class="form-group">
<div class="input-group date start_datetime">
<input type="text" class="form-control" />
<span class="input-group-addon"><span class="glyphicon-calendar glyphicon"></span></span>
</div>
</div>