From: Anthony Talarico Date: Wed, 27 Jul 2016 15:15:22 +0000 (-0400) Subject: testing logic for replacing invalid dates with the current date for off canvas reserv... X-Git-Tag: v1.0.0^2~252 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=df18c2dd08aff0ea6df58251d5a58efddf70a5ce;p=WP-Themes%2Fpetoskeyarea.git testing logic for replacing invalid dates with the current date for off canvas reservation widget --- diff --git a/js/app.js b/js/app.js index 1d62c0d..399d0d7 100644 --- a/js/app.js +++ b/js/app.js @@ -80,6 +80,7 @@ $(document).ready(function () { $("#departCal").click(function () { $(departure_date).datepicker("show"); }); + // get current date to set min for arrival date var today = new Date(); var day = today.getDate(); @@ -100,7 +101,6 @@ $(document).ready(function () { var extraDay, end, arrival, currentDate, currentDate2, currentDatePlusOne, requiredDate, requiredDate1, minDays, departure, stay, d, dd, m,mm, y; $(document).on('change', '#arriveOff', function () { - currentDate = $("#arriveOff").val(); currentDate = currentDate.replace(/-/g, "/"); @@ -134,7 +134,11 @@ $(document).ready(function () { requiredDate = y + '-' + m + '-' + d; minDays = y + '-' + mm + '-' + dd; $("#departOff").attr("min", minDays); - $("#departOff").val(""); + $("#departOff").val(""); + + if($("#arriveOff").val() < today){ + $("#arriveOff").val(today); + } }); // restrict departure date /////////////////////////////// diff --git a/js/custom/pageSetup.js b/js/custom/pageSetup.js index 81b6ffc..7c744d3 100644 --- a/js/custom/pageSetup.js +++ b/js/custom/pageSetup.js @@ -71,6 +71,7 @@ $(document).ready(function () { $("#departCal").click(function () { $(departure_date).datepicker("show"); }); + // get current date to set min for arrival date var today = new Date(); var day = today.getDate(); @@ -91,7 +92,6 @@ $(document).ready(function () { var extraDay, end, arrival, currentDate, currentDate2, currentDatePlusOne, requiredDate, requiredDate1, minDays, departure, stay, d, dd, m,mm, y; $(document).on('change', '#arriveOff', function () { - currentDate = $("#arriveOff").val(); currentDate = currentDate.replace(/-/g, "/"); @@ -125,7 +125,11 @@ $(document).ready(function () { requiredDate = y + '-' + m + '-' + d; minDays = y + '-' + mm + '-' + dd; $("#departOff").attr("min", minDays); - $("#departOff").val(""); + $("#departOff").val(""); + + if($("#arriveOff").val() < today){ + $("#arriveOff").val(today); + } }); // restrict departure date ///////////////////////////////