testing logic for replacing invalid dates with the current date for off canvas reserv...
authorAnthony Talarico <talarico@gaslightmedia.com>
Wed, 27 Jul 2016 15:15:22 +0000 (11:15 -0400)
committerAnthony Talarico <talarico@gaslightmedia.com>
Wed, 27 Jul 2016 15:15:22 +0000 (11:15 -0400)
js/app.js
js/custom/pageSetup.js

index 1d62c0d..399d0d7 100644 (file)
--- a/js/app.js
+++ b/js/app.js
@@ -80,6 +80,7 @@ $(document).ready(function () {
     $("#departCal").click(function () {
         $(departure_date).datepicker("show");
     });
+    
      // get current date to set min for arrival date
         var today = new Date();
         var day = today.getDate();
@@ -100,7 +101,6 @@ $(document).ready(function () {
     var extraDay, end, arrival, currentDate, currentDate2,          currentDatePlusOne, requiredDate, requiredDate1, minDays, departure, stay, d, dd,  m,mm, y;
     
    $(document).on('change', '#arriveOff', function () {
-       
       
         currentDate = $("#arriveOff").val();
         currentDate = currentDate.replace(/-/g, "/");
@@ -134,7 +134,11 @@ $(document).ready(function () {
         requiredDate = y + '-' + m + '-' + d;
         minDays = y + '-' + mm + '-' + dd;
         $("#departOff").attr("min", minDays);
-       $("#departOff").val("");
+        $("#departOff").val("");
+       
+       if($("#arriveOff").val() < today){
+            $("#arriveOff").val(today);
+        }
 
     });
     // restrict departure date ///////////////////////////////
index 81b6ffc..7c744d3 100644 (file)
@@ -71,6 +71,7 @@ $(document).ready(function () {
     $("#departCal").click(function () {
         $(departure_date).datepicker("show");
     });
+    
      // get current date to set min for arrival date
         var today = new Date();
         var day = today.getDate();
@@ -91,7 +92,6 @@ $(document).ready(function () {
     var extraDay, end, arrival, currentDate, currentDate2,          currentDatePlusOne, requiredDate, requiredDate1, minDays, departure, stay, d, dd,  m,mm, y;
     
    $(document).on('change', '#arriveOff', function () {
-       
       
         currentDate = $("#arriveOff").val();
         currentDate = currentDate.replace(/-/g, "/");
@@ -125,7 +125,11 @@ $(document).ready(function () {
         requiredDate = y + '-' + m + '-' + d;
         minDays = y + '-' + mm + '-' + dd;
         $("#departOff").attr("min", minDays);
-       $("#departOff").val("");
+        $("#departOff").val("");
+       
+       if($("#arriveOff").val() < today){
+            $("#arriveOff").val(today);
+        }
 
     });
     // restrict departure date ///////////////////////////////