jQuery detect submit on form problem I'm trying to detect when a form is submitted so I have written this code:

jQuery('#formid').submit(function(event){
        console.log('submit handler');
})


But nothing happens and the form is submitted normally. The form is rendered as usual and the submit button is generated with this code:

  $form['submit'] = array(
    '#type' =&gt; 'submit',
    '#value' =&gt; t('Enviar'),
    '#attributes' =&gt; array('class' =&gt; array('btn','pull-right')),
    '#ajax' =&gt; array(
        'callback' =&gt; 'contact_form_ajax_submit',
        'wrapper' =&gt; $result_wrapper,
        'progress' =&gt; array(
          'type' =&gt; 'none',
          'message' =&gt; NULL,
        ),
    ),
  );


I don't know why my jquery script doesn't intercept the submit. I've checked the form id (obviously) so I ask for help because I have no idea about what could be the problem.

Thanks

Link: http://seminolaproducciones.com/contacto
For normal forms you need bind submit event handler to the form, something like below as Baysaa said,

jQuery('#formid').submit(function() {
  console.log('submit handler');
  return false;
});


However For Drupal AJAX forms this wont work, Because Drupal AJAX forms are submitted by Drupal in a different way when the submit button is clicked, So you need to just bind the click event to the submit button to detect the form submission, Something like below,

jQuery('#submit-form').submit(function() {
  console.log('Form is being submitted');
});


Here the restriction is you cant prevent form being submitted, even if you put return false in you custom click handler.