How can I clear all check boxes on failed validation? I have form with check boxes. The user checks the boxes and hits the submit button. If validation fails an error message is displayed. I also want all of the user's checks to be cleared so they can try again. Here's my code, but it does not clear the checks? Thanks.

/**
 * Defines a form.
 */
function my_form($form, &amp;$form_state) {

    $form['alerts'] = array(
        '#type' =&gt; 'checkboxes',
        '#options' =&gt; $options,
    );

    // the rest of my form

    if (isset($form_state['clear_checkboxes'])) {
        $form_state['values']['alerts'] = array_fill(0, count($form_state['values']['alerts']), 0);
    }
    return $form;

}

/**
 * Form validator.
 */
function my_form_validate($form, &amp;$form_state) {

    // if validation fails set error message

    $form_state['rebuild'] = TRUE;
    $form_state['clear_checkboxes'] = TRUE;

}
You can unset your field in the form .Check for the array which has field array.

unset($form_state['field_checkbox']['und'][0]['value']);