bootstrap datetimepicker验证如何从其他选择器结束日期
<div class="well">
<div id="from-datepicker" class="input-append date">
<input data-format="dd/MM/yyyy hh:mm:ss" type="text"></input>
<span class="add-on">
<i data-time-icon="icon-time" data-date-icon="icon-calendar">
</i>
</span>
</div>
</div>
<div class="well">
<div id="to-datepicker" class="input-append date">
<input data-format="dd/MM/yyyy hh:mm:ss" type="text"></input>
<span class="add-on">
<i data-time-icon="icon-time" data-date-icon="icon-calendar">
</i>
</span>
</div>
</div>
<script>
$(function () {
$('#from-datepicker').datetimepicker({format: 'DD.MM.YYYY HH:mm',pickSeconds: false,pick12HourFormat: false});
$('#to-datepicker').datetimepicker({format: 'DD.MM.YYYY HH:mm',pickSeconds: false,pick12HourFormat: false});});
</script>
ToDate必须晚于FromDate。怎么做?
答案 0 :(得分:0)
您可以指定检查datetimepicker的更改事件。
$('#to-datepicker').datepicker().on('changeDate', function (ev) {
//if (to>from)
//code here
//else
//code here
});