From 179053ebb090cf7b7b8ae30ec03e2f54e1aa12c2 Mon Sep 17 00:00:00 2001 From: Anthony Talarico Date: Tue, 14 Aug 2018 12:17:49 -0400 Subject: [PATCH] fixing reservation widget to not accept negative numbers for the night stay --- js/app.js | 4 +++- js/custom/pageSetup.js | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/js/app.js b/js/app.js index 8acb59e..054a485 100644 --- a/js/app.js +++ b/js/app.js @@ -131,9 +131,11 @@ $(document).ready(function () { let formattedDate = `${year}-${month}-${day}`; _.val(formattedDate); let arrivalDate = new Date($("#arriveOff").val()); - if( !isNaN( getNights(departDate,arrivalDate) )){ + console.log( getNights(departDate,arrivalDate) < 0 ); + if( !isNaN( getNights(departDate,arrivalDate) ) && !getNights(departDate,arrivalDate) < 0){ $("#nightsOff").val( getNights(departDate,arrivalDate) ) stay = `stay_nights=${getNights(departDate,arrivalDate)}&`; + console.log(" ASDFASDF") }else { $("#nightsOff").val( 1 ) stay = `stay_nights=1&`; diff --git a/js/custom/pageSetup.js b/js/custom/pageSetup.js index e91b657..ae28d03 100644 --- a/js/custom/pageSetup.js +++ b/js/custom/pageSetup.js @@ -122,9 +122,11 @@ $(document).ready(function () { let formattedDate = `${year}-${month}-${day}`; _.val(formattedDate); let arrivalDate = new Date($("#arriveOff").val()); - if( !isNaN( getNights(departDate,arrivalDate) )){ + console.log( getNights(departDate,arrivalDate) < 0 ); + if( !isNaN( getNights(departDate,arrivalDate) ) && !getNights(departDate,arrivalDate) < 0){ $("#nightsOff").val( getNights(departDate,arrivalDate) ) stay = `stay_nights=${getNights(departDate,arrivalDate)}&`; + console.log(" ASDFASDF") }else { $("#nightsOff").val( 1 ) stay = `stay_nights=1&`; -- 2.17.1