I am using the basic JQuery UI datepicker, I need the date range with check in and check out but I need to add date + x days to the check out input.
How can I add x days to $.datepicker.parseDate( dateFormat, element.value );
Here is the code:
$(function() {
function getDate(element) {
var date;
try {
date = $.datepicker.parseDate(dateFormat, element.value);
} catch (error) {
date = null;
}
return date;
}
var dateFormat = 'dd MM yy',
from = $('#CheckIn')
.datepicker({
minDate: 0,
dateFormat: 'dd MM yy',
defaultDate: '+1w',
changeMonth: false,
numberOfMonths: 1
})
.on('change', function() {
to.datepicker('option', 'minDate', getDate(this));
}),
to = $('#CheckOut').datepicker({
dateFormat: 'dd MM yy',
defaultDate: '+1w',
changeMonth: true,
numberOfMonths: 1
})
.on('change', function() {
from.datepicker('option', 'maxDate', getDate(this));
});
});
When I select a date from "Check In" I want "Check Out" to only enable date + x days from the From selected day.
Any help would be much appreciated.
Thanks in advance!