How to set minDate and maxDate for bootstrap datetimepicker on change

前端 未结 3 1480
深忆病人
深忆病人 2021-01-06 19:07

I want to ask users for a date range using bootstrap datetimepicker. There is a field for the start date and another one for the end date, and they\'re initialized to the da

3条回答
  •  一向
    一向 (楼主)
    2021-01-06 19:15

    Based on the Linked Pickers example in the Bootstrap datetimepicker documentation, this should work.

    Start:

     .on('dp.change', function (selected) {
        end.data("DateTimePicker").minDate(selected.date);
     });
    

    End:

     .on('dp.change', function (selected) {
        start.data("DateTimePicker").maxDate(selected.date);
     });
    

    Note:

    On older versions of Bootstrap datetimepicker (less than v4), use .setMinDate and .setMaxDate

提交回复
热议问题