I have tried solving this problem by trying out the codes posted as answer from google and stackoverflow and it solved half of my problem but now my problem is that i can disable only those specific date below 2014-12-9. I want to be able to disable any specific date from any year or day or month. How do I solve this.
<script>
$(function() {
"use strict";
var holidays = [];
$.ajax({
type: "GET",
url: "<?= site_url() ?>/generalSettingController/getHolidays",
dataType: 'json',
success: function(data){
for(var i=0;i<data.length;++i){
holidays[i] = data[i]['date'];
}
//disableHolidays;
//console.log(disableHolidays);
}
});
function disableHolidays(date) {
var m = date.getMonth();
var d = date.getDate();
var y = date.getFullYear();
console.log(holidays);
debugger
for (var i = 0; i < holidays.length; ++i) {
if ($.inArray(y + '-' + (m + 1) + '-' + d, holidays) != -1) {
return [false];
}
}
var noWeekend = $.datepicker.noWeekends(date);
return !noWeekend[0] ? noWeekend : [true];
}
$('.datepicker').each(function(){
$(this).datepicker({
dateFormat: 'yy-mm-dd' ,
beforeShowDay: disableHolidays
});
});
});
</script>
So like there is an input field where the user clicks and the jquery calendar pops out and he can choose which date to disable but he cant choose those dates which are already disabled. Please help me solve this problem. Is it the problem of variable scope?