Reputation: 1219
So I am working with JQuery Datepicker, now I have 2 fields one for start date and one for end date. I am looking to make it so when the start date has been entered the end date can then be entered but must be after the start date. Now this I can do, however how can I go about if the start date has been changed that the date has changed in the end date.
Im not overly familiar with how this would work once a plugin has been initiated. I initiate it like this:
$( ".endDate" ).datepicker({
beforeShowDay : noWeekendsOrHolidays,
dateFormat: "yy/mm/dd",
minDate: new Date(<?=$start_date?>),
maxDate: new Date(<?=$yearend?>,<?=$monthend?>,<?=$dayend?>)
});
Can I do something like overwrite the min date at a later time so maybe I can add a change function to the start date so that it changes the min date again? but how after the plugin has been initiated can I overwrite the minDate
field?
Upvotes: 0
Views: 151
Reputation: 46323
You can change any jQuery UI option in the following way:
$('.endDate').datepicker('option', 'minDate', newValue);
That's a feature of the widget factory that jQuery UI uses.
Also, see the sample in the datepicker documentation.
Upvotes: 1