Testing date restrictions for firefox
authorAnthony Talarico <talarico@gaslightmedia.com>
Tue, 3 Nov 2015 14:58:03 +0000 (09:58 -0500)
committerAnthony Talarico <talarico@gaslightmedia.com>
Tue, 3 Nov 2015 14:58:03 +0000 (09:58 -0500)
js/app.js
js/custom/pageSetup.js

index 262c3b3..6c4b73e 100644 (file)
--- a/js/app.js
+++ b/js/app.js
@@ -44,7 +44,8 @@ $(document).ready(function () {
         //console.log('ul = ' + menuImg);
         //console.log('menu-id = ' + menuNum);
     });
-    //// Reservation Form logic /////////////////////////////
+    
+    //// Reservation Form logic //////////////////////////////////////////////////////////////////////////////////////////////////////
 
     // get the url to determine the page location
     page = $(location).attr('pathname');
@@ -67,42 +68,49 @@ $(document).ready(function () {
     $("#cal2").click(function () {
         $("#date2").datepicker("show");
     });
-    today = new Date();
-    minDays = 2;
-    today.setDate(today.getDate() + minDays);
-    d = today.getDate();
-    if (d <= 9) {
-        d = '0' + d;
-    }
-    m = today.getMonth() + 1;
-    if (m <= 9) {
-        m = '0' + m;
-    }
-    y = today.getFullYear();
-    requiredDate = y + '-' + m + '-' + d;
-    $("#dateOff1").val(requiredDate);
-    // restrict datepicker for days after current date and 2 days after that date [min]
-    $("#dateOff1").change(function () {
+    // restrict arrival date //////////////////////////////////////////////
+    $(document).on('change', '#dateOff1', function () {
         currentDate = $("#dateOff1").val();
-        today = new Date();
+        //alert(currentDate);
+        currentDate = new Date(currentDate);
+        currentDate = new Date(currentDate.getUTCFullYear(), currentDate.getUTCMonth(), currentDate.getUTCDate());
         minDays = 2;
-        today.setDate(today.getDate() + minDays);
-        d = today.getDate();
+        currentDate.setDate(currentDate.getDate());
+        d = currentDate.getDate();
         if (d <= 9) {
             d = '0' + d;
         }
-        m = today.getMonth() + 1;
+        m = currentDate.getMonth() + 1;
         if (m <= 9) {
             m = '0' + m;
         }
-        y = today.getFullYear();
+        y = currentDate.getFullYear();
         requiredDate = y + '-' + m + '-' + d;
-        if (currentDate !== requiredDate) {
-         
+        if (requiredDate < $('#dateOff1').attr("min")) {
+            minDays = $('#dateOff1').attr("min");
+            $("#dateOff1").val(minDays);
+        }
+    });
+    // restrict departure date ///////////////////////////////
+    $(document).on('change', '#dateOff2', function () {
+        currentDate = $("#dateOff1").val();
+        currentDate = new Date(currentDate);
+        currentDate = new Date(currentDate.getUTCFullYear(), currentDate.getUTCMonth(), currentDate.getUTCDate());
+        currentDate.setDate(currentDate.getDate());
+        d = currentDate.getDate() + 2;
+        if (d <= 9) {
+            d = '0' + d;
+        }
+        m = currentDate.getMonth() + 1;
+        if (m <= 9) {
+            m = '0' + m;
+        }
+        y = currentDate.getFullYear();
+        requiredDate = y + '-' + m + '-' + d;
+        if ($("#dateOff2").val() < $('#dateOff2').attr("min")) {
+            $("#dateOff2").val(requiredDate);
         }
-    
     });
-   
     $("#date1").datepicker({
         minDate: 2,
         onSelect: function (date) {
index 68d0dcc..47e8f45 100644 (file)
@@ -35,7 +35,8 @@ $(document).ready(function () {
         //console.log('ul = ' + menuImg);
         //console.log('menu-id = ' + menuNum);
     });
-    //// Reservation Form logic /////////////////////////////
+    
+    //// Reservation Form logic //////////////////////////////////////////////////////////////////////////////////////////////////////
 
     // get the url to determine the page location
     page = $(location).attr('pathname');
@@ -58,42 +59,49 @@ $(document).ready(function () {
     $("#cal2").click(function () {
         $("#date2").datepicker("show");
     });
-    today = new Date();
-    minDays = 2;
-    today.setDate(today.getDate() + minDays);
-    d = today.getDate();
-    if (d <= 9) {
-        d = '0' + d;
-    }
-    m = today.getMonth() + 1;
-    if (m <= 9) {
-        m = '0' + m;
-    }
-    y = today.getFullYear();
-    requiredDate = y + '-' + m + '-' + d;
-    $("#dateOff1").val(requiredDate);
-    // restrict datepicker for days after current date and 2 days after that date [min]
-    $("#dateOff1").change(function () {
+    // restrict arrival date //////////////////////////////////////////////
+    $(document).on('change', '#dateOff1', function () {
         currentDate = $("#dateOff1").val();
-        today = new Date();
+        //alert(currentDate);
+        currentDate = new Date(currentDate);
+        currentDate = new Date(currentDate.getUTCFullYear(), currentDate.getUTCMonth(), currentDate.getUTCDate());
         minDays = 2;
-        today.setDate(today.getDate() + minDays);
-        d = today.getDate();
+        currentDate.setDate(currentDate.getDate());
+        d = currentDate.getDate();
         if (d <= 9) {
             d = '0' + d;
         }
-        m = today.getMonth() + 1;
+        m = currentDate.getMonth() + 1;
         if (m <= 9) {
             m = '0' + m;
         }
-        y = today.getFullYear();
+        y = currentDate.getFullYear();
         requiredDate = y + '-' + m + '-' + d;
-        if (currentDate !== requiredDate) {
-         
+        if (requiredDate < $('#dateOff1').attr("min")) {
+            minDays = $('#dateOff1').attr("min");
+            $("#dateOff1").val(minDays);
+        }
+    });
+    // restrict departure date ///////////////////////////////
+    $(document).on('change', '#dateOff2', function () {
+        currentDate = $("#dateOff1").val();
+        currentDate = new Date(currentDate);
+        currentDate = new Date(currentDate.getUTCFullYear(), currentDate.getUTCMonth(), currentDate.getUTCDate());
+        currentDate.setDate(currentDate.getDate());
+        d = currentDate.getDate() + 2;
+        if (d <= 9) {
+            d = '0' + d;
+        }
+        m = currentDate.getMonth() + 1;
+        if (m <= 9) {
+            m = '0' + m;
+        }
+        y = currentDate.getFullYear();
+        requiredDate = y + '-' + m + '-' + d;
+        if ($("#dateOff2").val() < $('#dateOff2').attr("min")) {
+            $("#dateOff2").val(requiredDate);
         }
-    
     });
-   
     $("#date1").datepicker({
         minDate: 2,
         onSelect: function (date) {