Fixing bugs in the date picker min ranges
authorAnthony Talarico <talarico@gaslightmedia.com>
Tue, 10 Nov 2015 15:45:01 +0000 (10:45 -0500)
committerAnthony Talarico <talarico@gaslightmedia.com>
Tue, 10 Nov 2015 15:45:01 +0000 (10:45 -0500)
js/app.js
js/custom/pageSetup.js

index c22ceb9..468dbc6 100644 (file)
--- a/js/app.js
+++ b/js/app.js
@@ -53,6 +53,10 @@ $(document).ready(function () {
         }
         y = currentDate.getFullYear();
         requiredDate = y + '-' + m + '-' + d;
+        arrival = d + '-' + m + '-' + y;
+        arrival.toString();
+        arrival = arrival.replace(/\//g, "");
+        arrival = parseInt(arrival, 10);
         minDays = y + '-' + m + '-' + dd;
         $("#departOff").attr("min", minDays);
         start = "arrival_date=" + y + '-' + m + '-' + d + '&';
@@ -71,11 +75,6 @@ $(document).ready(function () {
             }
             y = currentDate.getFullYear();
             requiredDate = y + '-' + m + '-' + d;
-            
-            arrival = d + '-' + m + '-' + y;
-            arrival.toString();
-            arrival = arrival.replace(/\//g, "");
-            arrival = parseInt(arrival, 10);
             //$("#departOff").val(requiredDate);
         }
         
@@ -87,8 +86,8 @@ $(document).ready(function () {
         currentDate = new Date(currentDate.getUTCFullYear(), currentDate.getUTCMonth(), currentDate.getUTCDate());
         currentDate.setDate(currentDate.getDate());
         dd = currentDate.getDate() + 1;
-        if (d <= 9) {
-            d = '0' + d;
+        if (dd <= 9) {
+            dd = '0' + dd;
         }
         d = currentDate.getDate();
         if (d <= 9) {
@@ -101,6 +100,7 @@ $(document).ready(function () {
         y = currentDate.getFullYear();
         requiredDate = y + '-' + m + '-' + d;
         departure = d + '-' + m + '-' + y;
+        alert(departure);
         departure.toString();
         departure = departure.replace(/\//g, "");
         departure = parseInt(departure, 10);
index 8a5c35d..959b521 100644 (file)
@@ -44,6 +44,10 @@ $(document).ready(function () {
         }
         y = currentDate.getFullYear();
         requiredDate = y + '-' + m + '-' + d;
+        arrival = d + '-' + m + '-' + y;
+        arrival.toString();
+        arrival = arrival.replace(/\//g, "");
+        arrival = parseInt(arrival, 10);
         minDays = y + '-' + m + '-' + dd;
         $("#departOff").attr("min", minDays);
         start = "arrival_date=" + y + '-' + m + '-' + d + '&';
@@ -62,11 +66,6 @@ $(document).ready(function () {
             }
             y = currentDate.getFullYear();
             requiredDate = y + '-' + m + '-' + d;
-            
-            arrival = d + '-' + m + '-' + y;
-            arrival.toString();
-            arrival = arrival.replace(/\//g, "");
-            arrival = parseInt(arrival, 10);
             //$("#departOff").val(requiredDate);
         }
         
@@ -78,8 +77,8 @@ $(document).ready(function () {
         currentDate = new Date(currentDate.getUTCFullYear(), currentDate.getUTCMonth(), currentDate.getUTCDate());
         currentDate.setDate(currentDate.getDate());
         dd = currentDate.getDate() + 1;
-        if (d <= 9) {
-            d = '0' + d;
+        if (dd <= 9) {
+            dd = '0' + dd;
         }
         d = currentDate.getDate();
         if (d <= 9) {
@@ -92,6 +91,7 @@ $(document).ready(function () {
         y = currentDate.getFullYear();
         requiredDate = y + '-' + m + '-' + d;
         departure = d + '-' + m + '-' + y;
+        alert(departure);
         departure.toString();
         departure = departure.replace(/\//g, "");
         departure = parseInt(departure, 10);