1

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

Chris
  • 435
  • 7
  • 19

1 Answers1

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