fixing reservation widget to not accept negative numbers for the night stay
authorAnthony Talarico <talarico@gaslightmedia.com>
Tue, 14 Aug 2018 16:17:49 +0000 (12:17 -0400)
committerAnthony Talarico <talarico@gaslightmedia.com>
Tue, 14 Aug 2018 16:17:49 +0000 (12:17 -0400)
js/app.js
js/custom/pageSetup.js

index 8acb59e..054a485 100644 (file)
--- 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&`;
index e91b657..ae28d03 100644 (file)
@@ -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&`;