function hook_validate
Search API
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)
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_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_edit_group_form_validate in modules/
admin/ admin.groups.inc - Validate handler for edit group form.
- advise_what_if_selection_form_validate in modules/
advise/ advise.module - Validate handler for the what_if selection form. This is where we might, for example, make sure that if a non-dynamic degree was selected, that they can't proceed.
- form_basic_validate in includes/
render.inc - This is a very basic valiator for form API submission. All I really care about is making sure required fields have a value in them. If they do not, we will file a form_error.
File
- includes/
hook.api.php, line 323 - 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;
}
}