From: Anthony Talarico Date: Thu, 3 Dec 2015 13:34:05 +0000 (-0500) Subject: fixing datepicker logic X-Git-Tag: v1.0.0^2~159 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=87411a9033f1ee420a75b7fb0c6fe7c8ed392616;p=WP-Themes%2Fstaffords.git fixing datepicker logic --- 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(""); }