I'm using Davidwalsh's method for blocking out specific dates on the datepicker calender, but on my production server certain dates in the array aren't being blocked off, so I tried to do a clean replicate of the code, and discovered the similar discrepancies in the results.
Can someone kindly point out something I'm missing here ?
For some reason, 1 November is blocked out, and 4th nov is not being blocked out.
On my production server's situation, we tried to block out 2 dates in december, but they fail to get disabled. Dates from the current month get blocked fine.
Any help would be greatly appreciated!
$(document).ready(function(){
var cdates = new Array();
cdates = ['2012-11-04','2012-11-12','2012-12-03','2012-12-12','2012-12-18','2012-12-20'];
$('.datepicker').datepicker({
beforeShowDay: check_closed
});
function check_closed(date)
{ var m = date.getMonth(), d = date.getDate(), y = date.getFullYear();
for (i = 0; i < cdates.length; i++) {
if($.inArray(y + '-' + (m+1) + '-' + d,cdates) != -1 || new Date() > date) {
console.log('bad: ' + (m+1) + '-' + d + '-' + y + ' / ' + cdates[i]);
return [false,''];
}
console.log('good: ' + (m+1) + '-' + d + '-' + y);
return [true,''];
}
}
});