Setting min date in jQuery datepicker Setting min date in jQuery datepicker jquery jquery

Setting min date in jQuery datepicker


$(function () {    $('#datepicker').datepicker({        dateFormat: 'yy-mm-dd',        showButtonPanel: true,        changeMonth: true,        changeYear: true,yearRange: '1999:2012',        showOn: "button",        buttonImage: "images/calendar.gif",        buttonImageOnly: true,        minDate: new Date(1999, 10 - 1, 25),        maxDate: '+30Y',        inline: true    });});

Just added year range option. It should solve the problem


The problem is that the default option of "yearRange" is 10 years.

So 2012 - 10 = 2002.

So change the yearRange to c-20:c or just 1999 (yearRange: '1999:c'), and use that in combination with restrict dates (mindate, maxdate).

For more info: https://jqueryui.com/demos/datepicker/#option-yearRange


See example: (JSFiddle)

And your code with the addition:

$(function () {    $('#datepicker').datepicker({        dateFormat: 'yy-mm-dd',        showButtonPanel: true,        changeMonth: true,        changeYear: true,        showOn: "button",        buttonImage: "images/calendar.gif",        buttonImageOnly: true,        minDate: new Date(1999, 10 - 1, 25),        maxDate: '+30Y',        yearRange: '1999:c',        inline: true    });});


Hiya working demo: http://jsfiddle.net/femy8/

Now the calendar will only go to minimum of 1999-10-25.

Click on the image i.e. small icon next to text box for calendar to appear. You can try selecting up until 1999 but the minimum date for selection is 25th of oct 1999. which is what you want.

This will help, have a nice one! :) cheers!

Jquery Code

$(".mypicker").datepicker({    changeYear: true,    dateFormat: 'yy-mm-dd',    showButtonPanel: true,    changeMonth: true,    changeYear: true,    showOn: "button",        buttonImage: "images/calendar.gif",        buttonImageOnly: true,        minDate: new Date('1999/10/25'),        maxDate: '+30Y',        inline: true});​