//
//Block certain days in jQuery Datepicker
//
//
// Holiday List
var unavailableDates = ["9-3-2012", "14-3-2012", "15-3-2012"];
// Exeptions if some Weekends are Working days
var enableDay = ["3-3-2012", "10-3-2012", "17-3-2012"];
// Weekend Days Sunday = 0 ... Sat =6
var weekend = [0, 6];
function nationalDays(date) {
// get date
dmy = date.getDate() + "-" + (date.getMonth() + 1) + "-" + date.getFullYear();
// if Holiday then block it
if ($.inArray(dmy, unavailableDates) > -1) {
return [false, "", "Unavailable"];
}
// if Exception then Enable it
if ($.inArray(dmy, enableDay) > -1) {
return [true, ""];
}
//if Weekend then block it
if ($.inArray(date.getDay(), weekend) > -1) {
return [false, "", "Unavailable"];
}
return [true, ""];
}
$(function() {
$("#iDate").datepicker({
dateFormat: 'dd MM yy',
beforeShowDay: nationalDays
});
});
Comments
Post a Comment