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

前端 未结 3 2018
执笔经年
执笔经年 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: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 });
    });
    

提交回复
热议问题