mindate和maxdate在datepicker中不起作用

时间:2018-07-03 18:17:10

标签: javascript jquery

请帮助我找到我在这里犯的错误

$(document).ready(function () {
  $("#datepicker123").datepicker({
    defaultDate: new Date(),
    minDate: new Date()
  });
  $(function () {
    $('#datepicker123').removeClass('hasDatepicker');
    $('#datepicker123').datepicker({
      onSelect: function (dateText, inst) {
        $('#datepicker123').datepicker({
          dateFormat: 'dd-mm-yy'
        });
        var dateFormat = $('#datepicker123').datepicker('option', 'dd-mm-yy');
        $('#datepicker123').datepicker('option', 'dateFormat', 'dd-mm-yy');
        var result125 = $('#datepicker123').val();
        $.ajax({
          type: "POST",
          url: "getslot.php",
          data: {
            result: result125
          },
          success: function (res) {
            $('#getSlotDetails').html(res);
          }
        });
      }
    });
  });
});

但是过去的日子仍然可以选择,并且maxdate也不能将当前日期保留15天

我也尝试过 $(“#datepicker123”)。datepicker({     minDate:0 });

1 个答案:

答案 0 :(得分:0)

据我所知,应该这样做:

$("#datepicker").datepicker('option', {minDate: <some date>, maxDate: <some date>});

Reference taken

Live Example