jQuery UI Datepicker - Disable specific days
Posted
by Sam
on Stack Overflow
See other posts from Stack Overflow
or by Sam
Published on 2009-03-24T15:39:28Z
Indexed on
2010/04/30
0:47 UTC
Read the original article
Hit count: 339
Is there any (easy) way to set the jQuery UI Datepicker to disallow selection of specific, predetermined days?
I was able to get this approach working, however, it produces a null error which prevents it from displaying in IE.
'natDays[...].0' is null or not an object
Thanks in advance!
UPDATE: Might help if I included some code, right? Anyway, most of this was taken straight from the aforementioned thread:
natDays = [
[7, 23], [7, 24], [8, 13], [8, 14],
];
function nationalDays(date) {
for (i = 0; i < natDays.length; i++) {
if (date.getMonth() == natDays[i][0] - 1
&& date.getDate() == natDays[i][1]) {
return [false, natDays[i][2] + '_day'];
}
}
return [true, ''];
}
function noWeekendsOrHolidays(date) {
var noWeekend = $.datepicker.noWeekends(date);
if (noWeekend[0]) {
return nationalDays(date);
} else {
return noWeekend;
}
}
$(function() {
$("#datepicker").datepicker({
inline: true,
minDate: new Date(2009, 6, 6),
maxDate: new Date(2009, 7, 14),
numberOfMonths: 2,
hideIfNoPrevNext: true,
beforeShowDay: $.datepicker.noWeekends,
altField: '#alternate',
});
});
Thanks again!
© Stack Overflow or respective owner