对于那些面临从 dateA - dateB 禁用先前时间的人,其中 dateB 不能大于 dateA。我想在这里分享我的代码以提供帮助:)
var calImg = '@Url.Content("~/Images/ico_calendar.gif")';
var dtFormat = 'd-M-yy';
var showType = "button";
var dates = $("#newsDateFrom, #newsDateTo").datepicker({
dateFormat: dtFormat,
showOn: showType,
buttonImage: calImg,
buttonImageOnly: true,
numberOfMonths: 3,
onSelect: function (selectedDate) {
var option = this.id == "newsDateFrom" ? "minDate" : "maxDate",
instance = $(this).data("datepicker"),
date = $.datepicker.parseDate(
instance.settings.dateFormat ||
$.datepicker._defaults.dateFormat,
selectedDate, instance.settings);
dates.not(this).datepicker("option", option, date);
}
});