I'm trying to disable dates returned from an array, problem is the disabled dates are not in the correct order, Jan's dates are showing in Feb, Feb's dates are showing in Mar and Mar are not showing at all as per image
The code is below
<script>
$(function () {
var bDates = [{ start: new Date(2019, 01, 06), end: new Date(2019, 01, 17) },
{ start: new Date(2019, 02, 05), end: new Date(2019, 02, 07) },
{ start: new Date(2019, 03, 07), end: new Date(2019, 03, 10) }];
var dateFormat = 'yyyy mm dd',
from = $( "#from" ).datepicker({
defaultDate: "+1w",
changeMonth: true,
numberOfMonths: 3,
minDate:0,
beforeShowDay: function(date) {
for (var i = 0; i < bDates.length; i++) {
if (date >= bDates[i].start && date <= bDates[i].end) return [false, ''];
}
return [true, ''];
}
})
.on( "change", function() {
to.datepicker( "option", "minDate", getDate( this ) );
}),
to = $( "#to" ).datepicker({
defaultDate: "+1w",
changeMonth: true,
numberOfMonths: 3
})
.on( "change", function() {
from.datepicker( "option", "maxDate", getDate( this ) );
});
} );
</script>
Can anyone spot what I'm doing wrong