如何在jQuery UI日期选择器中禁用公共假期?

Jim*_*ong 5 html javascript jquery datepicker jquery-ui-datepicker

我正在做假期预订申请,显然你不需要预订已经给你的假期,所以我需要知道如何禁用,圣诞节,例如每年的日期选择器,而不需要我每年更改代码.

到目前为止,这是我的jQuery UI日期选择器代码:

<script>
$(function() {
  $("#from").datepicker({
      beforeShowDay: $.datepicker.noWeekends,
      defaultDate: "today",
      changeMonth: true,
      numberOfMonths: 1,
      minDate: "today",
      dateFormat: "dd/mm/yy",
      onClose: function(selectedDate) {
        $( "#to" ).datepicker("option", "minDate", selectedDate);
      }
  });
  $("#to").datepicker({
    beforeShowDay: $.datepicker.noWeekends,
    defaultDate: "today",
    changeMonth: true,
    numberOfMonths: 1,
    minDate: "today",
    dateFormat: "dd/mm/yy",
    onClose: function(selectedDate) {
      $("#from").datepicker("option", "maxDate", selectedDate);
    }
  });
});
</script>
Run Code Online (Sandbox Code Playgroud)

Ano*_*shi 13

你可以排除日期之类的

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 ]
}
});
Run Code Online (Sandbox Code Playgroud)

您可以为假期阵列提供更多日期