From 70dcb0d441c3993e867c618c7aee58c7ddb45275 Mon Sep 17 00:00:00 2001 From: Anthony Talarico Date: Mon, 2 Nov 2015 16:32:31 -0500 Subject: [PATCH] Error checking and validation for mobile phones, no native date min rnage for firefox --- js/app.js | 31 ++++++++++++++++++------------- js/custom/pageSetup.js | 31 ++++++++++++++++++------------- 2 files changed, 36 insertions(+), 26 deletions(-) diff --git a/js/app.js b/js/app.js index f7e5a12..065c7ae 100644 --- 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) { diff --git a/js/custom/pageSetup.js b/js/custom/pageSetup.js index 4501882..5763f07 100644 --- a/js/custom/pageSetup.js +++ b/js/custom/pageSetup.js @@ -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) { -- 2.17.1