function hook_validate

Validates form submissions from the Form API

This function can be named anything you want (or can be considered optional). If named the same thing as the form callback, it will be utilized automatically. For example, if you form is named my_form, then if you have a validate function named my_form_validate, it will be called automatically.

Since $form_state is passed by reference, you may make changes to this array, and those changes will carry through to other validate functions (defined with #validate_handlers) and then to the submit handler(s).

See also

hook_submit($form, &$form_state)

28 functions implement hook_validate()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

admin_add_degree_form_validate in modules/admin/admin.degrees.inc
Validate handler for add_degree_form
admin_apply_draft_changes_form_validate in modules/admin/admin.module
Before we apply changes, make sure the password is correct.
admin_copy_degree_form_validate in modules/admin/admin.degrees.inc
Validate handler. Make sure our allow_overwrite setting is working. Check for existing major code.
admin_duplicate_year_form_validate in modules/admin/admin.module
Before we duplicate the year, make sure the password is correct.
admin_edit_degree_form_validate in modules/admin/admin.degrees.inc

... See full list

File

includes/hook.api.php, line 392
Lists all available hooks within FlightPath's core code.

Code

function hook_validate($form, &$form_state) {
  $age = $form_state ["values"]["age"];
  if ($age < 18) {
    form_error("age", "Sorry, you must be 18 or older to submit this form.");
    return;
  }
}