This question already has an answer here:

I would like to not validate fields if I submit button with ajax callback. Currently, on every button click it displays validation errors of another fields. The button doesn't submit the form, it does some another action (add more fields).

marked as duplicate by Clive Jul 17 '13 at 8:26

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


You need to set limit_validation_errors to an empty array for it to ignore the rest of the fields in the form. Here's an example:

  $form['a_field'] = array(
    '#type' => 'button',
    '#limit_validation_errors' => array(),
    '#value' => t('Click here'),
    '#name' => 'a_field',
    '#submit' => array('my_submit_function'),
    '#ajax' => array(
      'callback' => 'my_function',
      'wrapper' => 'my_wrapper',

Not the answer you're looking for? Browse other questions tagged or ask your own question.