The user has 2 inputs on the page and should be able to pick any date range that is within 3 months from the startdate to the enddate. The enddate should also never be earlier then the startdate which the same check prevents startdate from being later than the enddate. Is there a way to include the date range restriction in the datepicker without external validation? The dates the user can choose is not limited to how far back they can go. If they want data from 2 years ago, they can pull a 3 month period from that year. At page load, enddate is 2 days from today and startdate is todays date.
EDIT:
$(function () {
$("#startDate").datepicker({
onSelect: function (selectedDate) {
var orginalDate = new Date(selectedDate);
var monthsAddedDate = new Date(new Date(orginalDate).setMonth(orginalDate.getMonth() + 3));
alert(monthsAddedDate);
$("#endDate").datepicker("option", 'minDate', selectedDate);
$("#endDate").datepicker("option", 'maxDate', monthsAddedDate);
}
});
$("#endDate").datepicker({
onSelect: function (selectedDate) {
var orginalDate = new Date(selectedDate);
var monthsAddedDate = new Date(new Date(orginalDate).setMonth(orginalDate.getMonth() - 3));
alert(monthsAddedDate);
$("#startDate").datepicker("option", 'minDate', selectedDate);
$("#startDate").datepicker("option", 'maxDate', monthsAddedDate);
}
})
});