How to change end date automatically after changing start date? I would like to be able to automatically change the value of the end date to be the same as the start date after changing the start date.

Ex: right after changing the start date to 12-12-12, the end date would be the same.

Here's what I did so far:

Added the following code in a custom module (form_modif) :

$form['#attached']['js'][] = drupal_get_path('module', 'form_modif') . '/custom_alter.js';


Witch seems fine, I can see that the script is added in the code source of the page

The JS file's code is :

(function ($) { 
  Drupal.behaviors.form_modif = { 
    attach: function(context, settings) { 
      $('.field_date_1').change(function(){
        $field_date1 = $(.FIELD_DATE_2').val();
        $('.field_date_2').val($field_date1);
      });
    } 
  }; 
});(jQuery);


And that's where my problem seems to be, I'm not very good in JS, could someone help me with that?

Here's the HTML code of thoses fields if that can help:

Start date field:

&lt;input class="date-clear form-text hasDatepicker date-popup-init" type="text" id="edit-field-date-und-0-value-datepicker-popup-0" name="field_date[und][0][value][date]" value="31/01/2014" size="20" maxlength="30"&gt;


End date field:

&lt;input class="date-clear form-text hasDatepicker date-popup-init" type="text" id="edit-field-date-und-0-value2-datepicker-popup-0" name="field_date[und][0][value2][date]" value="31/01/2014" size="20" maxlength="30"&gt;
I did it the way pretty much mentioned in question with some corrections.

My code with javascript file is 

// Change the end date value to same as that of start date.
Drupal.behaviors.form_modif = {
  attach: function (context, settings) {
        $('input#edit-field-event-date-und-0-value-datepicker-popup-0').change(function(){
        var field_date1 = $('input#edit-field-event-date-und-0-value-datepicker-popup-0').val(); 
        $('input#edit-field-event-date-und-0-value2-datepicker-popup-0').val(field_date1);
    });
  }
};


}(jQuery));