Error checking and validation for mobile phones, no native date min rnage for firefox
authorAnthony Talarico <talarico@gaslightmedia.com>
Mon, 2 Nov 2015 21:32:31 +0000 (16:32 -0500)
committerAnthony Talarico <talarico@gaslightmedia.com>
Mon, 2 Nov 2015 21:32:31 +0000 (16:32 -0500)
js/app.js
js/custom/pageSetup.js

index f7e5a12..065c7ae 100644 (file)
--- a/js/app.js
+++ b/js/app.js
@@ -69,19 +69,24 @@ $(document).ready(function () {
     });
   
     // restrict datepicker for days after current date and 2 days after that date [min]
-    today = new Date();
-    minDays = 2;
-    today.setDate(today.getDate() + minDays);
-    d = today.getDate();
-    m = today.getMonth() + 1;
-    y = today.getFullYear();
-    requiredDate = y + '-' + m + '-' + d;
-    
-    currentDate = document.getElementById('dateOff1');
-
-    currentDate.addEventListener('change', function () {
-        currentDate.value = new Date(currentDate.value).toISOString().split('T')[0];
-    }, false);
+    $("#dateOff1").change(function () {
+        today = $("#dateOff1").val();
+        today = new Date(today);
+        minDays = 2;
+        today.setDate(today.getDate());
+        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;
+        alert(requiredDate);
+    });
+   
     $("#date1").datepicker({
         minDate: 2,
         onSelect: function (date) {
index 4501882..5763f07 100644 (file)
@@ -60,19 +60,24 @@ $(document).ready(function () {
     });
   
     // restrict datepicker for days after current date and 2 days after that date [min]
-    today = new Date();
-    minDays = 2;
-    today.setDate(today.getDate() + minDays);
-    d = today.getDate();
-    m = today.getMonth() + 1;
-    y = today.getFullYear();
-    requiredDate = y + '-' + m + '-' + d;
-    
-    currentDate = document.getElementById('dateOff1');
-
-    currentDate.addEventListener('change', function () {
-        currentDate.value = new Date(currentDate.value).toISOString().split('T')[0];
-    }, false);
+    $("#dateOff1").change(function () {
+        today = $("#dateOff1").val();
+        today = new Date(today);
+        minDays = 2;
+        today.setDate(today.getDate());
+        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;
+        alert(requiredDate);
+    });
+   
     $("#date1").datepicker({
         minDate: 2,
         onSelect: function (date) {