Second ajax button not working on user profile form I have added a custom button which has an ajax callback with the following code to the user profile form.

$form['validate_2'] = array(
          '#type' =&gt; 'button',
          '#value' =&gt; t('validate 2'),
          '#ajax' =&gt; array(
            'callback' =&gt; 'example_validate',
            'wrapper' =&gt; 'validate-settings',
            'method' =&gt; 'replace'
          ),
          '#name' =&gt; 'user_validate_2',
          '#id' =&gt; 'user-validate-2',
          '#weight' =&gt; 10
        );


But when I click on it, it gives me ajax error in popup saying

An AJAX HTTP request terminated abnormally.
Debugging information follows.
Path: /system/ajax
StatusText: n/a
ResponseText: 
( ! ) Fatal error: Call to undefined function user_profile_form_validate() in /includes/form.inc on line 1520


In my ajax callback I'm simply displaying the $form_state array. Any idea what I'm doing wrong?

The form's own submit button is not with ajax.

function example_validate($form, &amp;$form_state) {
dsm($form_state);
}
If Drupal can't find one of its core files it's nearly always because you're trying to use it in a context in which it wouldn't be automatically included.

For example when you use the user profile form normally, the menu item makes sure the file containing the form functions is included.

For your example the missing function is in user.pages.inc, so:

form_load_include($form_state, 'inc', 'user', 'user.pages');