【问题标题】:How to automatically disable dates after got selected via calender #jQuery #Drupal8如何在日历中选择后自动禁用日期#jQuery #Drupal8
【发布时间】:2020-05-14 14:51:50
【问题描述】:

我为 drupal 8 站点创建了自定义表单并采用了日期类型字段。我想在被选中后禁用日期,比如预订一些插槽类型。我见过很多使用 .datepicker() 的代码。但是当我使用这段代码时,它会显示两个日历。我想为此使用 jQuery。请给点建议

谢谢

【问题讨论】:

标签: javascript jquery drupal-8


【解决方案1】:

在使用 jQuery 选择日期后,使用以下代码禁用日期字段。希望下面的代码可以帮助到你。

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js">
</script>
  <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
  <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
  <link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script>
$(document).ready(function(){


$(function() {
    $('#datepicker').datepicker( {
        onSelect: function() {
            $('#datepicker').attr('disabled','disabled');
        }

    });
});


});

</script>
</head>
<body>
<p>Date: <input type="text" id="datepicker" ></p>

</body>
</html>

Here is the reference

【讨论】:

    猜你喜欢
    • 2019-01-02
    • 1970-01-01
    • 1970-01-01
    • 2014-11-10
    • 1970-01-01
    • 1970-01-01
    • 2020-01-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多