0

对于那些面临从 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);
        }
    });
4

1 回答 1

0

使用最小日期选项,如 $( ".selector" ).datepicker({ minDate: new Date(2007, 1 - 1, 1) }); 参考http://api.jqueryui.com/datepicker/#option-minDate

于 2013-10-30T09:30:17.287 回答