How can I set the minDate/maxDate for jQueryUI Datepicker using a string?

前端 未结 3 1993
执笔经年
执笔经年 2021-01-14 11:56

jQueryUI Datepicker documentation states that the minDate option can be set using \"a string in the current dateFormat\". So I\'ve tried the following to initialize datepick

相关标签:
3条回答
  • 2021-01-14 12:14

    I found your last method to be best for IE7/8 anyway. IE returns NaN in string-fed Date functions; as soon as I parsed to numbers the problem disappeared.

    0 讨论(0)
  • 2021-01-14 12:30

    In the end I had to use something like this, since the v1.7 datepicker has no probs with Dates:

    $.getJSON("/GetMinMaxDates/", function(dates) {
        var DateLimits = {min:null, max:null};
    
        DateLimits.min = new Date(Date.parse(dates.min));
        DateLimits.max = new Date(Date.parse(dates.max));
    
        $("input.date").datepicker({ dateFormat: "mm/dd/yy", minDate: DateLimits.min, maxDate: DateLimits.max });
    });
    
    0 讨论(0)
  • 2021-01-14 12:30

    Appears to be a "bug" in 1.3.2 with 1.7.2. In 1.4.2 with 1.8.1 all is fine.

    0 讨论(0)
提交回复
热议问题