I am working on ASP.net Webform application where i need to block certain dates and Weekend as Friday & Saturday.
Following Code works fine, It block the dates but by default blocks Saturday & Sunday as weekend while i need to block all Fridays & Saturdays on calendar.
I would appreciate fix to this particular code. I am not sure if jQuery Calendar has a built-in property to specify different weekends
var holiDays = [[2012, 07, 06, 'New Years Day'], [2012, 07, 14, 'Event XYZ'], [2011, 17, 25, 'Christmas Day']];
$(function () {
$("#<%=txtBookDate.ClientID %>").datepicker({
dateFormat: "yy-mm-dd",
minDate: "-0d",
maxDate: "+60d",
beforeShowDay: noWeekendsOrHolidaysOrBlockedDates
});
function noWeekendsOrHolidaysOrBlockedDates(date) {
var noWeekend = jQuery.datepicker.noWeekends(date);
return noWeekend[0] ? setHoliDays(date) : noWeekend;
}
// set holidays function which is configured in beforeShowDay
function setHoliDays(date) {
for (i = 0; i < holiDays.length; i++) {
if (date.getFullYear() == holiDays[i][0]
&& date.getMonth() == holiDays[i][1] - 1
&& date.getDate() == holiDays[i][2]) {
return [false, 'holiday', holiDays[i][3]];
}
}
return [true, ''];
}
});
Do you not have access to the jQuery UI source? Odd, because it is javascript, and usually freely available:
Looks pretty well non-customizable, but relatively easy to reimplement as your own function.