I don't know much about J-Query but I am using a J-Query UI-date picker in a program I am creating. My program allows you to book off holidays in the company but I want to disable every Christmas Day on the calendar and every New Years day as the employees will already have this date off. Thanks
Asked
Active
Viewed 596 times
1
-
1http://stackoverflow.com/questions/15400775/jquery-ui-datepicker-disable-array-of-dates – Jamie Dunstan Feb 06 '14 at 10:56
-
I want to disable every Christmas and new year, not just dates that are in an array – Chris Feb 06 '14 at 14:11
1 Answers
5
To disable all Christmas days / new years days, you could do something like this:
function IsChristmas(date) {
var day = date.getDate();
var month = date.getMonth() + 1;
return (day === 25 && month === 12);
}
function IsNewYearsDay(date) {
var day = date.getDate();
var month = date.getMonth() + 1;
return (day === 1 && month === 1);
}
$('input').datepicker({
beforeShowDay: function (date) {
return [(!IsChristmas(date) && !IsNewYearsDay(date))];
}
});
Check out this JSFiddle for a demo.

Jamie Dunstan
- 3,725
- 2
- 24
- 38
-
1I hope you don't mind but I have also used this and it works fine, thanks for sharing. – HaydnJW Mar 31 '14 at 14:45
-
1