Jquery- 如何设置今天之前的日期不能是select?

Jquery- How to set the date before today can't be select?

我可以让今天的日期出现在入住日期,但问题是用户仍然可以选择今天之前的日期。是否有任何解决方案可以让我解决他的问题?任何建议都会有很大的帮助,谢谢!

$(function () {
        $("#chkI").datepicker({
            dateFormat: "yy-mm-dd", showAnim: "slideDown", 
            onClose: function (selectedDate) {
                var minDate = $(this).datepicker('getDate');
                var newMin = new Date(minDate.setDate(minDate.getDate() + 1));
                $("#chkO").datepicker("option", "minDate", newMin);
            }
        });
        var currentDate = new Date();
        $("#chkI").datepicker("setDate", currentDate);
        $("#chkO").datepicker({ dateFormat: "yy-mm-dd", showAnim: "slideDown",
            onClose: function (selectedDate) {
                var maxDate = $(this).datepicker('getDate');
                var newMax = new Date(maxDate.setDate(maxDate.getDate() - 1));
                $("#chkI").datepicker("option", "maxDate", newMax);
            }
        });
    });

您只需要设置 minDate 并且不要为相同的输入再次初始化日期选择器

$(function () {
            $("#chkI").datepicker({
                minDate: new Date(), // start date should be today's date
                dateFormat: "yy-mm-dd", showAnim: "slideDown", 
                onClose: function (selectedDate) {
                    var minDate = $(this).datepicker('getDate');
                    var newMin = new Date(minDate.setDate(minDate.getDate() + 1));
                    $("#chkO").datepicker("option", "minDate", newMin);
                }
            }).datepicker("setDate", new Date()); // select today's date by default
            //var currentDate = new Date();
            //$("#chkI").datepicker("setDate", currentDate);
            $("#chkO").datepicker({ dateFormat: "yy-mm-dd", showAnim: "slideDown",
                onClose: function (selectedDate) {
                    var maxDate = $(this).datepicker('getDate');
                    var newMax = new Date(maxDate.setDate(maxDate.getDate() - 1));
                    $("#chkI").datepicker("option", "maxDate", newMax);
                }
            });
        });
 <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
  <link rel="stylesheet" href="/resources/demos/style.css">
  <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>
<input type="text" id="chkI">
<input type="text" id="chk0">

这就是我禁用今天之前日期的方式:

$("#chkI").datepicker({
    minDate: new Date()
});

例如jsfiddle