我正在使用日期选择器我的问题是我今天选择日期接下来7天的日期已启用,现在如果我在今天日期之前选择日期,则接下来的7天没有禁用,日期选择器从今天起计7天,
var dateFormat = "yy-mm-dd",
from = $("#fromdate").datepicker({
defaultDate: "+1w",
changeMonth: false,
maxDate: "7d",
minDate: new Date(2010, 1 - 1, 1),
altField: "#actualDate",
numberOfMonths: 1,
dateFormat: 'yy-mm-dd'
}).on("change", function () {
to.datepicker("option", "minDate", getDate(this));
}),
to = $("#todate").datepicker({
// defaultDate: "+1w",
changeMonth: false,
numberOfMonths: 1,
maxDate: "7d",
dateFormat: 'yy-mm-dd'
}).on("change", function () {
from.datepicker("option", "maxDate", getDate(this));
});
function getDate(element) {
var date;
try {
date = $.datepicker.parseDate(dateFormat, element.value);
} catch (error) {
date = null;
}
return date;
}