I have a form with 3 input fields that use jQuery's DatePicker plugin. The fields are #startdate, #enddate, and #raindate. I am using DatePicker's event function to get the #startdate and #enddate to work together so the #enddate cannot be before the #startdate. Both those fields are required, by the way. The #raindate field is not required. However, if the user wants to add a date here, I want it to be after the date selected in the #enddate. How do I do this? Here is the code I have for getting the startdate and enddate to work together:
function getDates() {
var dates = $("#startdate, #enddate" ).datepicker({
defaultDate: "+1d",
changeMonth: true,
numberOfMonths: 1,
onSelect: function( selectedDate ) {
var option = this.id == "startdate" ? "minDate" : "maxDate",
instance = $( this ).data( "datepicker" );
date = $.datepicker.parseDate(
instance.settings.dateFormat ||
$.datepicker._defaults.dateFormat,
selectedDate, instance.settings );
dates.not( this ).datepicker( "option", option, date );
}
});
}
Is there a way to specify something like this?:
minDate: $(#enddate).val() + 1d