简体   繁体   中英

mindate and maxdate not working in datepicker

Please help me to find what mistake i am doing here

$(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);
          }
        });
      }
    });
  });
});

But still old days are able to select and maxdate also not able to keep 15 days from current day

i have tried this too $("#datepicker123").datepicker({ minDate: 0 });

As far as I know, it should be done like this:

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

Reference taken

Live Example

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM