简体   繁体   中英

The jQuery Datepicker maxDate doesn't seem to work

I have a problem with jQuery and my datepicker.

I've got this:

$(function() {
   $("#datepicker").datepicker({
      minDate: '02/16/2012',
      maxDate: '04/15/2017',
      buttonImage:"calendar.gif"
    });
});

When I go on my datepicker, the minDate work, the maxDate is set (I check it on console) but the maxDate is not respected, I can choose a day after my maxDate .

EDIT : sorry for your time, it was just the data which were wrong, it was in the dd/mm/yy format so it's normal that it doesn't work, with good data it work as describe in jquery API documentation

Change your code to look like the example in my fiddle and everything should work for you.

SEE FIDDLE

$( "#datepicker" ).datepicker({
        minDate: "02/16/2012",
        maxDate: "04/15/2017",
        buttonImage:"ui-icon-calendar"
});

<input type="text" id="datepicker" />

The min and max date properties take strings or variables, so wrap the dates in quotes, then remove the semi colon from the last property.

Also take a look at the API documentation .

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