jQuery UI Picking a start and end date within range based on start date

后端 未结 3 1381
深忆病人
深忆病人 2021-02-13 13:39

I\'m building a date picker in jQuery ui. What I\'m trying to do is set a range, so when they pick the first date the second date appears and gives a 30 day window. I tried this

3条回答
  •  野的像风
    2021-02-13 14:24

    Try using the ui onSelect callback instead of .change(), http://api.jqueryui.com/datepicker/#option-onSelect

    on init:

    var $datepickerStart = $("#datepickerStart");
    $datepickerStart.datepicker({
        onSelect: function( selectedDate ) {
            $datepickerStart.datepicker( "option", "minDate", selectedDate );
        }
    });
    

提交回复
热议问题