Ajax on a webform affecting comment form and user-registration form I have Ajaxified a webform using a (hook) custom module. The code used is:
 function alterwebform_form_alter(&amp;$form, &amp;$form_state, $form_id) {
    
    //see if webform_client_form_ is in the form_id
     
    if(strstr($form_id, 'webform_client_form_')) {  
    
      //get the nid so we can use it in the wrapper value

       $nid = $form['#node']-&gt;nid;
   
        $form['actions']['submit']['#ajax'] = array(
            'callback' =&gt; 'alterwebform_webform_js_submit',
            'wrapper' =&gt; 'webform-client-form-' . $nid,
            'method' =&gt; 'replace',
            'effect' =&gt; 'fade',
     );

  $form['#validate'] []='alterwebform_test';
      }
    }

The code in the callback function is:
function alterwebform_webform_js_submit(&amp;$form, &amp;$form_state, $form_id) {

  // define the $sid variable (submission id from webform)
    $sid = $form_state['values']['details']['sid'];
  
 // sid to know the form was properly submitted
   
    if ($sid) {
  
  //load up the webform node object

     $node = node_load($form_state['values']['details']['nid']);

  //create an array with the confirmation message of webform
        $confirmation = array(
                 '#type' =&gt; 'markup',
                 '#markup' =&gt; check_markup($node-&gt;webform['confirmation'], $node-&gt;webform['confirmation_format'], '', TRUE),
                     );

  // return the confirmation message
    return $confirmation;
    }
  else {
   // return the form
       return $form;
        }
    }

The web-form works fine . The problem is: The AJAX code above is affecting other forms (Comments form and User Register form).

How is it affecting ?

If other (comment and user-register) forms are submitted successfully in the first time then its fine. But if there is some error in the first time and we submit second time, then  click on submit does not perform any action but show ajax effect.
The click on submit button now shows ajax kind of affect but is without any action.

As you can see in the picture, the ajax affect comes in this form. This happens if someone is clicking the button the second time (because of some error on first time).
What could be the possible reason for this and how should I fix this? Thank you in advance.
The problem can be that ajax functionality is attached to button by its id attribute. Seems all three buttons - for webform, comment and user-register have the same id "edit-submit".

To fix this - just add unique id for webform submit button.

function alterwebform_form_alter(&amp;$form, &amp;$form_state, $form_id) {

//see if webform_client_form_ is in the form_id
if(strstr($form_id, 'webform_client_form_')) {  

  //get the nid so we can use it in the wrapper value
   $nid = $form['#node']-&gt;nid;

    $form['actions']['submit']['#ajax'] = array(
        'callback' =&gt; 'alterwebform_webform_js_submit',
        'wrapper' =&gt; 'webform-client-form-' . $nid,
        'method' =&gt; 'replace',
        'effect' =&gt; 'fade',

    );
    // Add unique id for submit button.
    $form['actions']['submit']['#id'] = 'webform-client-form-submit-' . $nid;

    $form['#validate'] []='alterwebform_test';
  }
}