Changing to date field based on from date using javascript I have a form written using Drupal's FAPI (Drupal v7.15). The form includes two date fields - a from date and a to date. I've installed the Date module and both fields are both set-up to use the 'date_popup' widget.

Now I want to make the to date automatically change when the from date is updated by the user. Eg if the user sets the from date to 1st Nov 2012, I want the to date to automatically change to match the from date. Ideally I would also like the date picker to disable all options earlier than this date. This is the same behaviour you see on many travel sites, such as expedia.com.

I can't find a good example of how to add the Javascript to do this. I can only see AJAX examples, and it seems unnecessary to make a round trip to the server to do this - the browser has all the info it needs to do so client side.
If I understand you right it should be as simple as dropping something like this into a JS file included in the page:

(function($) {
  Drupal.behaviors.myModule = {
    attach: function(context, settings) {
      $('#edit-from-date', context).change(function() {
        $('#edit-to-date', context).val($(this).val());
      });
    }
  }
})(jQuery);


Disabling certain dates is a bit more complicated but there's an example here that should point you in the right direction.