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,
});
$(function() {
$( "#datepicker" ).datepicker({
changeYear: true,
minDate: '-3M',
maxDate: '+28D',
});
});
UPDATE
You can calculate tour max and min valid dates from the default date, then assign it to the date picker.
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,
minDate: '-3M',
maxDate: '+28D',
});