0
1个月范围的日期将在过去的日期1个月范围日期过去将工作日期jQuery UI的
例如
工作将来日期将禁用(#to_date)
https://jsfiddle.net/swaroop206/vpe54c29/4/
$(document).ready(function(){
$('#from_date').datepicker({
changeMonth: true,
changeYear: true,
dateFormat: "yy-mm-dd",
maxDate: new Date(),
onSelect: function (selectedDate) {
var orginalDate = new Date(selectedDate);
var monthsAddedDate = new Date(new Date(orginalDate).setMonth(orginalDate.getMonth() + 1));
$("#to_date").datepicker("option", 'minDate', selectedDate);
$("#to_date").datepicker("option", 'maxDate', monthsAddedDate);
}
}).click(function(){
$('.ui-datepicker-calendar').show();
});
$('#to_date').datepicker({
changeMonth: true,
changeYear: true,
dateFormat: "yy-mm-dd",
maxDate: new Date(),
onSelect: function (selectedDate) {
var orginalDate = new Date(selectedDate);
var monthsAddedDate = new Date(new Date(orginalDate).setMonth(orginalDate.getMonth() - 1));
$("#from_date").datepicker("option", 'minDate', monthsAddedDate);
$("#from_date").datepicker("option", 'maxDate', selectedDate);
}
}).click(function(){
$('.ui-datepicker-calendar').show();
});
});
</script>
你想要什么输出? – Amy
意思是如果你选择5月9日。那么在第6个日期的日期中将被禁用。 – Amy
查看我更新的答案。 – Amy