如何将假期等受阻日期添加到日期选择器?

问题描述 投票:0回答:1

我需要帮助来禁用 jquery 日期选择器上的特定日期。我已成功阻止星期日,但我不知道如何将阻止的日期添加到日历中。我查看了现有的问题和答案,但里面的解决方案不起作用。这是我必须写的脚本。我将非常感谢帮助。我不是程序员。

{{ '//code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css' | stylesheet_tag }}

<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js" defer="defer"></script>

    <div style="width:100%; clear:both; margin: 10px 0;">
    <p>
    <label for="date">CHOOSE A DELIVERY/PICKUP DATE:</label>
    <input readonly="readonly" id="date" type="text" name="attributes[date]" value="{{ cart.attributes.date }}" />
    </p>
    </div>

    <script>  
    window.onload = function() {
      if (window.jQuery) {
        let $ = window.jQuery;

        $(function() {
          $("#date").datepicker({
          minDate: +2,
          maxDate: '+6M',
          beforeShowDay: noSundays,
          dateFormat: "dd/mm/yy"  
        });
      });

    function noSundays(date){
      if (date.getDay() === 0)  /* Sunday */
            return [ false, "", "" ]
      else
            return [ true, "", "" ]
      }        
    }
  }
</script>
jquery datepicker jquery-ui-datepicker
1个回答
0
投票
blockedDays.push('2023-11-9');
© www.soinside.com 2019 - 2024. All rights reserved.