From: Anthony Talarico Date: Tue, 3 Nov 2015 14:58:03 +0000 (-0500) Subject: Testing date restrictions for firefox X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=c4e8213f47b96d02e46de74b7ef469f1a8803009;p=WP-Themes%2Fglmthemes%2Fbpla-theme.git Testing date restrictions for firefox --- diff --git a/js/app.js b/js/app.js index 262c3b3..6c4b73e 100644 --- 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) { diff --git a/js/custom/pageSetup.js b/js/custom/pageSetup.js index 68d0dcc..47e8f45 100644 --- a/js/custom/pageSetup.js +++ b/js/custom/pageSetup.js @@ -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) {