Speed up development with full-stack environments for every branch.

Learn More

jquery datepicker set end date based on start date [JavaScript]

Forked from How to use the jQuery $().ready function.

2561 Runs 9340 Views 5283 Copies

some HTML5 magic

Saved

Saved

a3csdev 2

a3csdev
published 2 years ago

    /*  jQuery ready function. Specify a function to execute when the DOM is fully loaded.  */
    $(document).ready(
      //var dropoffdate;
      /* This is the function that will get executed after the DOM is fully loaded */
      function () {
        $( "#pickup_date" ).datepicker({
          //changeMonth: true,//this option for allowing user to select month
          //changeYear: true //this option for allowing user to select from year range
          minDate: new Date(),
          onSelect : function(selected_date){
            var selectedDate = new Date(selected_date);
            var msecsInADay = 86400000;
            var endDate = new Date(selectedDate.getTime() + msecsInADay);
            
             $("#dropoff_date").datepicker( "option", "minDate", endDate );
          }
        });
        
        $('#dropoff_date').datepicker({});
      }
      
      
    );
    Please login/signup to get access to the terminal.

    Your session has timed out.

    Dismiss (the page may not function properly).