0

All other attributes like format ,autoclose etc are working, but maxDate/minDate is not working.

Any help would be appreciated.

I am using bootstrap-datetimepicker

$(function() {
  $("#fdate").datetimepicker({
    format: 'yyyy-mm-dd',
    pickTime: false,
    startView: 'month',
    minView: 'month',
    autoclose: true,
    maxDate: '0'
  });
});
Rajesh
  • 24,354
  • 5
  • 48
  • 79
Justin
  • 91
  • 1
  • 8
  • Check this: http://stackoverflow.com/questions/11899472/jquery-datepicker-range-mindate-maxdate-is-not-working – Rajesh Dec 19 '16 at 05:22

3 Answers3

0

Isn't it suppose to be a date value. And also it seems you forgot to use the option in it.

$("#datepicker").datepicker('option', {minDate: <some date>, maxDate: <some date>});

Please have a look here.

Sibeesh Venu
  • 18,755
  • 12
  • 103
  • 140
0

-> At first see that have you imported the correct path for bootstrap-datetimepicker

$('#date').datepicker('option', { minDate: new Date(startDate), maxDate: new Date(endDate) });
NARGIS PARWEEN
  • 1,489
  • 3
  • 16
  • 26
0

Thanks to Nargis ,Rajesh & sibeesh for your Quick replies..

I Solved the problem ..

The problem was maxDate and minDate are attributes used in some other plugin (i think jquery datatime picker) . as I am using an old Bootstrap plugin ,The valid attributes are startDate and endDate

The worked code is below

$(function() {
    $( "#fdate" ).datetimepicker(
      {
         format: 'yyyy-mm-dd',
        pickTime: false,
        startView: 'month',
        minView: 'month',
        autoclose: true,   
         startDate: '-1d',//previous date
         endDate: new Date()//current date
      });
});
Justin
  • 91
  • 1
  • 8