From: Anthony Talarico Date: Tue, 14 Aug 2018 16:17:49 +0000 (-0400) Subject: fixing reservation widget to not accept negative numbers for the night stay X-Git-Tag: v1.0.49^2~1 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/index.cgi?a=commitdiff_plain;h=179053ebb090cf7b7b8ae30ec03e2f54e1aa12c2;p=WP-Themes%2Fstaffords.git fixing reservation widget to not accept negative numbers for the night stay --- 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&`;