$("#kidsOff").val("");
$(document).on('change', '#arriveOff', function () {
+
currentDate = $("#arriveOff").val();
currentDate = new Date(currentDate);
currentDate = new Date(currentDate.getUTCFullYear(), currentDate.getUTCMonth(), currentDate.getUTCDate());
start = "arrival_date=" + y + '-' + m + '-' + d + '&';
minDays = y + '-' + m + '-' + dd;
$("#departOff").attr("min", minDays);
- $("#nightsOff").val(Math.ceil(currentDate2 - currentDate) / (1000 * 60 * 60 * 24));
- if ($("#nightsOff").val() <= 0) {
- $("#departOff").val("Minimum 1 Night");
+ if ($("#departOff").val() === "Departure Date" || $("#departOff").val() === "") {
$("#nightsOff").val("");
+ } else {
+ $("#nightsOff").val(Math.ceil(currentDate2 - currentDate) / (1000 * 60 * 60 * 24));
}
- if ($("#departOff").val() === "Departure Date") {
+ if ($("#nightsOff").val() <= 0) {
+ $("#departOff").val("Minimum 1 Night");
$("#nightsOff").val("");
}
});
$("#kidsOff").val("");
$(document).on('change', '#arriveOff', function () {
+
currentDate = $("#arriveOff").val();
currentDate = new Date(currentDate);
currentDate = new Date(currentDate.getUTCFullYear(), currentDate.getUTCMonth(), currentDate.getUTCDate());
start = "arrival_date=" + y + '-' + m + '-' + d + '&';
minDays = y + '-' + m + '-' + dd;
$("#departOff").attr("min", minDays);
- $("#nightsOff").val(Math.ceil(currentDate2 - currentDate) / (1000 * 60 * 60 * 24));
- if ($("#nightsOff").val() <= 0) {
- $("#departOff").val("Minimum 1 Night");
+ if ($("#departOff").val() === "Departure Date" || $("#departOff").val() === "") {
$("#nightsOff").val("");
+ } else {
+ $("#nightsOff").val(Math.ceil(currentDate2 - currentDate) / (1000 * 60 * 60 * 24));
}
- if ($("#departOff").val() === "Departure Date") {
+ if ($("#nightsOff").val() <= 0) {
+ $("#departOff").val("Minimum 1 Night");
$("#nightsOff").val("");
}
});