0

i am using bootstrap datepicker and i want to disabled previous dates but nothing will work.

this is what i tried so far

<input type="text" name="a" class="datepicker form-control"/>

$('.datepicker').datepicker({
    format: 'mm-dd-yyyy',
    minDate: new Date(),
    maxDate: '+1y'
});

////////

$('.datepicker').datepicker({
    format: 'mm-dd-yyyy',
    startDate: '05-18-2016'
});

but nothing will work.

omer khan
  • 3
  • 1
  • Possible duplicate of [Bootstrap datepicker disabling past dates without current date](http://stackoverflow.com/questions/16123056/bootstrap-datepicker-disabling-past-dates-without-current-date) – JYoThI May 30 '16 at 12:29
  • startDate: new Date() – JYoThI May 30 '16 at 12:30

1 Answers1

0

Try this:

var nowTemp = new Date();
var now = new Date(nowTemp.getFullYear(), nowTemp.getMonth(), nowTemp.getDate(), 0, 0, 0, 0);

$('.datepicker').datepicker({
  onRender: function(date) {
    return date.valueOf() < now.valueOf() ? 'disabled' : '';
  }
});
Naqash Malik
  • 1,707
  • 1
  • 12
  • 14