Hi, I have 2 inputs called ArrivalDate and DepartureDate using jQuery datepicker which needs to det the departure date at least one more day from the selected arrival date. All works fine, except when we reach the end of the month insted of the departure date rolling over to the next month it just +1's the date. Eg today its showing 31 April, which dosent exsist.
$.datepicker.setDefaults({
changeMonth: true,
changeYear: true,
dateFormat: 'd/m/yy',
firstDay: 1
});
var myDate = new Date();
var prettyDate = myDate.getDate() + '/' + (myDate.getMonth()+1) + '/' + myDate.getFullYear();
var prettyDate2 = (myDate.getDate()+1) + '/' + (myDate.getMonth()+1) + '/' + myDate.getFullYear();
$('#ArrivalDate').datepicker({
minDate: new Date(),
onSelect: function(dateStr) {
var min = $(this).datepicker('getDate') || new Date(); // Selected date or today if none
$('#DepartureDate').datepicker('option', {minDate: min});
}
});
$('#DepartureDate').datepicker({
minDate: new Date(),
onSelect: function(dateStr) {
var max = $(this).datepicker('getDate'); // Selected date or null if none
$('#ArrivalDate').datepicker('option', {maxDate: max});
}
});
$("#ArrivalDate").val(prettyDate);
$("#DepartureDate").val(prettyDate2);