0

我得到了一个更好的例子,用没有时间的日期选择器验证期间。是否可以同时使用日期和时间进行验证?

示例来自: http ://www.jquerybyexample.net/2012/01/end-date-should-not-be-greater-than.html

$(document).ready(function() {
  $("#txtFromDate").datepicker({
    minDate: 0,
    maxDate: "+60D",
    numberOfMonths: 2,
    onSelect: function(selected) {
      $("#txtToDate").datepicker("option", "minDate", selected)
    }
  });
  $("#txtToDate").datepicker({
    minDate: 0,
    maxDate: "+60D",
    numberOfMonths: 2,
    onSelect: function(selected) {
      $("#txtFromDate").datepicker("option", "maxDate", selected)
    }
  });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"></script>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css" /> From:
<input type="text" id="txtFromDate" /> To:
<input type="text" id="txtToDate" />

4

0 回答 0