From a9b72aaa35f99acc21cc14076cbdccaa4a1fdc04 Mon Sep 17 00:00:00 2001 From: Anthony Talarico Date: Wed, 2 Dec 2015 16:58:33 -0500 Subject: [PATCH] fixing min days logic for off canvas res form --- js/app.js | 11 +++++++++-- js/custom/pageSetup.js | 11 +++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/js/app.js b/js/app.js index 2ffa2bc..0133814 100644 --- a/js/app.js +++ b/js/app.js @@ -50,6 +50,10 @@ $(document).ready(function () { currentDate = new Date(currentDate); currentDate = new Date(currentDate.getUTCFullYear(), currentDate.getUTCMonth(), currentDate.getUTCDate()); currentDate.setDate(currentDate.getDate()); + dd = currentDate.getDate() + 1; + if (dd <= 9) { + dd = '0' + dd; + } d = currentDate.getDate(); if (d <= 9) { d = '0' + d; @@ -60,13 +64,16 @@ $(document).ready(function () { } y = currentDate.getFullYear(); 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"); $("#nightsOff").val(""); } - stay - + if ($("#departOff").val() === "Departure Date") { + $("#nightsOff").val(""); + } }); // restrict departure date /////////////////////////////// $(document).on('change', '#departOff', function () { diff --git a/js/custom/pageSetup.js b/js/custom/pageSetup.js index 0b399ec..ae20a7f 100644 --- a/js/custom/pageSetup.js +++ b/js/custom/pageSetup.js @@ -41,6 +41,10 @@ $(document).ready(function () { currentDate = new Date(currentDate); currentDate = new Date(currentDate.getUTCFullYear(), currentDate.getUTCMonth(), currentDate.getUTCDate()); currentDate.setDate(currentDate.getDate()); + dd = currentDate.getDate() + 1; + if (dd <= 9) { + dd = '0' + dd; + } d = currentDate.getDate(); if (d <= 9) { d = '0' + d; @@ -51,13 +55,16 @@ $(document).ready(function () { } y = currentDate.getFullYear(); 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"); $("#nightsOff").val(""); } - stay - + if ($("#departOff").val() === "Departure Date") { + $("#nightsOff").val(""); + } }); // restrict departure date /////////////////////////////// $(document).on('change', '#departOff', function () { -- 2.17.1