How do I set Min Date in Datepicker from another Datepicker?

后端 未结 2 977
故里飘歌
故里飘歌 2021-01-06 06:20

I am currently adding validation to my date pickers and am having trouble setting the min date in the to date picker to be whatever was chosen in the

2条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-06 06:32

    Please check this working fiddle

    JSFiddle

    Use option to set the minDate to the second datepicker

    $("#from").datepicker({
            defaultDate: new Date(),
            minDate: new Date(),
            onSelect: function(dateStr) 
            {         
                $("#to").val(dateStr);
                $("#to").datepicker("option",{ minDate: new Date(dateStr)})
            }
        });
    

提交回复
热议问题