I have a datepicker which has the following configuration:
HTML:
<div class="input-group date">
<input type="text" id="datepick" class="form-control"/>
<span class="input-group-addon">
<i class="glyphicon glyphicon-calendar"></i>
</span>
</div>
JS:
var datesToDisable = ["2016-11-01","2016-08-01","2016-06-01",
"2016-05-01","2016-04-01","2015-12-01","2015-09-01"];
$('#datepick').datepicker({
format: 'yyyy-mm-dd',
minViewMode: 1, // 1 for months
maxViewMode: 2, // 2 for years
startDate: '-36m',
endDate: '+0m',
autoclose: true,
toggleActive: true
});
$('#datepick').datepicker('setDatesDisabled', datesToDisable);
Then later an async call retrieves an array of dates (here represented by the datesToDisable
variable) which are passed to the datepicker using the setDatesDisabled
method (as indicated on the last line of the code snippet), but it is not working, as the months for the passed dates are still selectable within the calendar.
Questions: Is this the correct way to set disabled months in the bootstrap datepicker calendar? Will I need to pass all dates within a month to disable a particular month?
You can check it in the following jsfiddle: http://jsfiddle.net/javlc/52g9xcz2/