bootstrap datetimepicker验证来自其他选择器的结束日期

时间:2014-07-24 12:32:09

标签: javascript jquery twitter-bootstrap datepicker

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。怎么做?

1 个答案:

答案 0 :(得分:0)

您可以指定检查datetimepicker的更改事件。

$('#to-datepicker').datepicker().on('changeDate', function (ev) {
    //if (to>from)
       //code here
    //else 
       //code here
});