How to restrict the selectable date ranges in Bootstrap Datepicker?

前端 未结 6 937
孤城傲影
孤城傲影 2020-11-27 02:42

I need to use datepicker which provides me the option of restricting the selectable dates. We had been using jQuery UI which is used to support it using minDate, maxDate opt

6条回答
  •  隐瞒了意图╮
    2020-11-27 03:30

    i am using v3.1.3 and i had to use data('DateTimePicker') like this

    var fromE = $( "#" + fromInput );
    var toE = $( "#" + toInput );
    $('.form-datepicker').datetimepicker(dtOpts);
    
    $('.form-datepicker').on('change', function(e){
       var isTo = $(this).attr('name') === 'to';
    
       $( "#" + ( isTo ? fromInput : toInput  ) )
          .data('DateTimePicker')[ isTo ? 'setMaxDate' : 'setMinDate' ](moment($(this).val(), 'DD/MM/YYYY'))
    });
    

提交回复
热议问题