By default, if we say
{minDate: 4}
in the options, the minimum selected date will be four days from Today.
Is it possible to change the date()
to be set in the future?
so, say we have a second date picker but we want the second date to assume that Today is a date set in a previous date picker element. We'll say it's 05/03/2020
Is there any way that we can set the next datepicker input to be set to as if it was that day, so that I can use the {minDate: 4}
and it will adjust the settings in relation to the previously selected date?
Maybe something like this:
$('.date_to_do_something').eq(1).datepicker({
setTheDate : '05/03/2020',
minDate : 5,
maxDate: 10
})
probably explained a little better:
By default, the datepicker knows what today is and applies the custom options i.e. {minDate:5} in relation to today. I would like to change the Today for the second date picker so that it thinks that the date set in the previous field is today. So if we set it to 05/03/2020 the next date picker will have have minimum date of 05/08/2020 I hope that makes sense!
yes, add the date picker so that the second is updated in relation to the first - use the on close event,
edit: also set the default date of the to to +5d to meet the it must start 5 days ahead of now requirement
see
HTML
<label for="from">From</label>
<input type="text" id="from" name="from" />
<label for="to">to</label>
<input type="text" id="to" name="to" />
SCRIPT
$(function() {
$( "#from" ).datepicker({
changeMonth: true,
minDate: "+0d",
onClose: function( selectedDate ) {
var minDate = $.datepicker.parseDate('mm/dd/yy', selectedDate);
minDate.setDate(minDate.getDate() + 5);
$( "#to" ).datepicker( "option", "minDate", minDate);
}
});
$( "#to" ).datepicker({minDate : "+5d"});
});