简体   繁体   中英

datepicker - next and prev button are not working after adding maxDate

I am using datepicker as follows:

$(".datepicker").datepicker({
        monthNames: datepickerResources.monthNames,
        dayNames: datepickerResources.dayNames,
        dayNamesShort: datepickerResources.dayNamesShort,
        dayNamesMin: datepickerResources.dayNamesMin,
        minDate: 0,
        maxDate: "+4w -1d",
        numberOfMonths: [12, 1],
        beforeShowDay: function (date) {
            var date1 = $.datepicker.parseDate($.datepicker._defaults.dateFormat, $("#input1").val());
            var date2 = $.datepicker.parseDate($.datepicker._defaults.dateFormat, $("#input2").val());
            return [true, SetDateColor(date, date1, date2)];
        },
        onSelect: function (dateText, inst) {
            var date1 = $.datepicker.parseDate($.datepicker._defaults.dateFormat, $("#input1").val());
            var date2 = $.datepicker.parseDate($.datepicker._defaults.dateFormat, $("#input2").val());
            if (!date1 || date2) {
                $("#input1").val(dateText);
                $("#input2").val("");
                $(this).datepicker();
            } else {
                $("#input2").val(dateText);
                $(this).datepicker();
            }
        }
    });

After I define the maxDate, the prev and the next button stop working and are in disable although there are active days also on the next month. Thanks for the help

You display 12 months simultaneously: numberOfMonths: [12, 1], .

  • The maxDate property sets the maximum allowed date from now plus 4 weeks minus 1 day.
  • The minDate property limits the oldest date by current date.

With such limits the possible date range is from now to now + 4 weeks - 1 day . The full range is already shown, so it is not possible to press the next or prev buttons.

If you set to show only one month ( numberOfMonths: 1, ) it is possible to go to the next page with such range.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM