How do i disable public holidays in a jQuery UI date picker?

后端 未结 2 1655
Happy的楠姐
Happy的楠姐 2020-12-30 15:00

I\'m making a holiday booking application and obviously you don\'t need to book off holidays that are already given to you, so I need to know how I can disable, Christmas, f

相关标签:
2条回答
  • 2020-12-30 15:47

    You have to use beforeShowDay attribute of DatePicker like below:

    $("#textboxid").datepicker({
    beforeShowDay: function(date) {
    var day = date.getDay();
    return [day != 0,''];
    }
    })​​​​​;​
    

    Above script will disable all Sundays.

    0 讨论(0)
  • 2020-12-30 15:49

    you can exclude the dates like

    var holidays = ["2014-02-27","2014-02-01"];
    $( "#from" ).datepicker({
    beforeShowDay: function(date){
        var datestring = jQuery.datepicker.formatDate('yy-mm-dd', date);
        return [ holidays.indexOf(datestring) == -1 ]
    }
    });
    

    you can provide more dates to the holidays array

    0 讨论(0)
提交回复
热议问题