1

I want to be able to disable some bank holidays which take place every year for example Christmas but I also want to be able to disable days which only happen one year

This is my code I have already

  var unavailableDates = ["25-12", "26-12", "1-1"];

    function unavailable(date) {
        dmy = date.getDate() + "-" + (date.getMonth() + 1);
        if ($.inArray(dmy, unavailableDates) == -1) {
            return [true, ""];
        } else {
            return [false, "", "Unavailable"];
        }
    }


    function noWeekendsOrHolidays(date) {
        var noWeekend = jQuery.datepicker.noWeekends(date);
        return noWeekend[0] ? unavailable(date) : noWeekend;
    }

Any body know how to do this?

2 Answers 2

1

Call like this :

$(".selector").datepicker({ beforeShowDay: noWeekendsOrHolidays})   
Sign up to request clarification or add additional context in comments.

Comments

0

http://api.jqueryui.com/datepicker/#option-beforeShowDay the api of jQuery UI Datepicker

beforeShowDay    Type: Function( Date date )

Default: null
A function that takes a date as a parameter and must return an array with:
[0]: true/false indicating whether or not this date is selectable
[1]: a CSS class name to add to the date's cell or "" for the default presentation
[2]: an optional popup tooltip for this date
The function is called for each day in the datepicker before it is displayed. 

JQuery DatePicker and beforeShowDay

and this may help

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.