I'm using Jquery UI datepicker in one of my projects. I need to disable US holiday dates. I tried jQuery UI Datepicker - Disable specific days and Can the jQuery UI Datepicker be made to disable Saturdays and Sundays (and holidays)?
But they didn't work. How can I make the special days unselectable.
I also tried it with http://tokenposts.blogspot.com/2011/05/jquery-datepicker-disable-specific.html, snippet is working appart, but not in my project. Here it's:
var unavailableDates = ["31-12-2012"];
function unavailable(date) {
dmy = date.getDate() + "-" + (date.getMonth()+1) + "-" + date.getFullYear();
if ($.inArray(dmy, unavailableDates) == -1) {
return [true, ""];
} else {
return [false,"","Unavailable"];
}
}
Drupal.behaviors.date_popup = function (context) {
for (var id in Drupal.settings.datePopup) {
$('#'+ id).bind('focus', Drupal.settings.datePopup[id], function(e) {
if (!$(this).hasClass('date-popup-init')) {
var datePopup = e.data;
// Explicitely filter the methods we accept.
switch (datePopup.func) {
case 'datepicker':
$(this)
.datepicker({ minDate: +1, maxDate: "+3Y", beforeShow: unavailable })
.addClass('date-popup-init')
$(this).click(function(){
$(this).focus();
});
break;
case 'timeEntry':
$(this)
.timeEntry(datePopup.settings)
.addClass('date-popup-init')
$(this).click(function(){
$(this).focus();
});
break;
}
}
});
}
};