Executing jQuery code during form submission I developed a module to show an "End" button on the node edit form, and it works fine.

function renew_form_alter(&amp;$form, &amp;$form_state, $form_id) {
  $form['actions']['property_endlease'] = array(
    '#type' =&gt; 'submit',
    '#value' =&gt; t('End'),
    '#access' =&gt; TRUE,
    '#weight' =&gt; 15,
  );

  return $form;
}


I want that, when users click on that button, some fields are changed from jQuery code. 

I tried the following code, but it doesn't show any alert, even though the form is submitted.

jQuery('#edit-property-end').click(function (event) {
  alert('');
});


I want to submit the form after the jQuery code is executed.

Does anybody have an idea on how to do this?

Thanks
Try this 

   $form['actions']['property_endlease'] = array(
            '#type' =&gt; 'submit',
            '#value' =&gt; t('End'),
            '#access' =&gt; TRUE,
            '#weight' =&gt; 15,
            '#attributes' =&gt; array("onclick" =&gt; "javascript:test();"),

        );


and create a custom js 

function test()  {
//your code 
}


Hope it will work