jquery datetime picker set minDate dynamic

前端 未结 9 1186
野趣味
野趣味 2020-11-29 11:12

I guys i\'m using a datetimepicker by trentrichardson.com.

I have a form with two input fields : from and to and i want to be able

9条回答
  •  伪装坚强ぢ
    2020-11-29 11:46

    If you have two textboxes with corresponding IDs from and to and you want the minDate of to to be the selected date of from then do the following:

    $("#from").datepicker({
        minDate: 0, // to disable past dates (skip if not needed)
        onClose: function(selectedDate) {
            // Set the minDate of 'to' as the selectedDate of 'from'
            $("#to").datepicker("option", "minDate", selectedDate);
        }
    });
    
    $("#to").datepicker();
    

提交回复
热议问题