I have the jQuery date picker setup and working but would like help with setting the minDate and maxDate options. My current code is below (without these options). How can I set the minDate as 3 months before the defaultDate, and maxDate as 28days after the defaultDate?
var expdisp = $("#expdisp").attr("value");
$("#expirydate" ).datepicker({
showOn: "button",
buttonImage: "images/calendar.gif",
buttonImageOnly: true,
dateFormat: "dd/mm/yy",
defaultDate: expdisp,
showOtherMonths: true,
selectOtherMonths: true,
changeMonth: true,
changeYear: true,
});
Your could try:
maxDate :- Sets the maximum date that can be selected. Accepts a date object or a relative number. For example: +7, or a string such as +6m.
minDate :- Sets the minimum date that can be selected. Accepts a number, date object, or string.
});
Refer:-set Minimum and maximum date to jquery datepicker
You can also use specific date ranges. I added a min beginning date with a +14D max. You just need to remember to stay consistent with your date format and use "/" instead of "-" between MM/DD/YYYY.
JSFiddle Demo
UPDATE
You can calculate tour max and min valid dates from the default date, then assign it to the date picker.
Update Demo