我的日期范围在下面的例子,我想为我的#checkout输入设置最小日期。从我的#checkin.#checkout搜索日期中选择一天后,日期范围不能超过15天,这就是为什么我要阻止它
$(function() {
var dateFormat = "DD/MM/YY",
from = $("#checkin,.checkin").datepicker({
numberOfMonths: 2,
firstDay: 1,
minDate: 0,
onSelect: function(selectedDate) {
window.setTimeout($.proxy(function() {
$(this).parents(".book-holiday").find("#checkout,.checkout").focus();
}, this), 10);
var yenitarih = new Date();
var date = $(this).datepicker('getDate');
date.setTime(date.getTime() + (1000 * 60 * 60 * 24));
$("#checkout,.checkout").datepicker("option", "minDate", date);
},
isTo1: true,
}).on("change", function() {
to.datepicker("option", "minDate", getDate(this));
}),
to = $("#checkout,.checkout").datepicker({
firstDay: 1,
numberOfMonths: 2,
minDate: 0,
maxDate: +15,
onSelect: function(selectedDate) {
$(this).parents(".book-holiday").find(".popover-wrapper").addClass("open");
$("#checkin,.checkin").datepicker("option", "maxDate", selectedDate);
},
}).on("change", function() {
from.datepicker("option", "maxDate", getDate(this));
});
});<link href="//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.10.0/css/smoothness/jquery-ui-1.10.0.custom.min.css" rel="stylesheet" />
<div class="book-holiday">
<input type="text" id="checkin" />
<input type="text" id="checkout" />
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
https://stackoverflow.com/questions/44795893
复制相似问题