From 87411a9033f1ee420a75b7fb0c6fe7c8ed392616 Mon Sep 17 00:00:00 2001 From: Anthony Talarico Date: Thu, 3 Dec 2015 08:34:05 -0500 Subject: [PATCH] fixing datepicker logic --- js/app.js | 12 +++++++++++- js/custom/pageSetup.js | 12 +++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/js/app.js b/js/app.js index 56c973d..481c34d 100644 --- a/js/app.js +++ b/js/app.js @@ -64,15 +64,25 @@ $(document).ready(function () { m = '0' + m; } y = currentDate.getFullYear(); + + // this variable is for passing to booking site start = "arrival_date=" + y + '-' + m + '-' + d + '&'; + + requiredDate = y + '-' + m + '-' + d; minDays = y + '-' + m + '-' + dd; $("#departOff").attr("min", minDays); + if (requiredDate < $("#arriveOff").attr("min")) { + minDays = $("#arriveOff").attr("min"); + $("#arriveOff").val(minDays); + $("#departOff").val($("#departOff").attr("min")); + } + if ($("#departOff").val() === "Departure Date" || $("#departOff").val() === "") { $("#nightsOff").val(""); } else { $("#nightsOff").val(Math.ceil(currentDate2 - currentDate) / (1000 * 60 * 60 * 24)); } - if ($("#nightsOff").val() <= 0) { + if ($("#nightsOff").val() <= 0) { $("#departOff").val("Minimum 1 Night"); $("#nightsOff").val(""); } diff --git a/js/custom/pageSetup.js b/js/custom/pageSetup.js index b20d1e6..78e0aa7 100644 --- a/js/custom/pageSetup.js +++ b/js/custom/pageSetup.js @@ -55,15 +55,25 @@ $(document).ready(function () { m = '0' + m; } y = currentDate.getFullYear(); + + // this variable is for passing to booking site start = "arrival_date=" + y + '-' + m + '-' + d + '&'; + + requiredDate = y + '-' + m + '-' + d; minDays = y + '-' + m + '-' + dd; $("#departOff").attr("min", minDays); + if (requiredDate < $("#arriveOff").attr("min")) { + minDays = $("#arriveOff").attr("min"); + $("#arriveOff").val(minDays); + $("#departOff").val($("#departOff").attr("min")); + } + if ($("#departOff").val() === "Departure Date" || $("#departOff").val() === "") { $("#nightsOff").val(""); } else { $("#nightsOff").val(Math.ceil(currentDate2 - currentDate) / (1000 * 60 * 60 * 24)); } - if ($("#nightsOff").val() <= 0) { + if ($("#nightsOff").val() <= 0) { $("#departOff").val("Minimum 1 Night"); $("#nightsOff").val(""); } -- 2.17.1