| CARVIEW |
Select Language
HTTP/2 301
date: Sat, 27 Dec 2025 02:16:03 GMT
content-type: text/html; charset=UTF-8
location: https://docs.gravityforms.com/gform_form_validation_errors/
server: cloudflare
strict-transport-security: max-age=604800
strict-transport-security: max-age=31536000; includeSubDomains
x-content-type-options: nosniff
x-content-type-options: nosniff
x-xss-protection: 1; mode=block
x-xss-protection: 1; mode=block
x-frame-options: SAMEORIGIN
x-frame-options: SAMEORIGIN
content-security-policy: frame-ancestors 'self';
referrer-policy: no-referrer
referrer-policy: strict-origin-when-cross-origin
x-redirect-by: WordPress
fastcgi-cache: EXPIRED
cf-cache-status: DYNAMIC
nel: {"report_to":"cf-nel","success_fraction":0.0,"max_age":604800}
report-to: {"group":"cf-nel","max_age":604800,"endpoints":[{"url":"https://a.nel.cloudflare.com/report/v4?s=XkAzDR7pdakmrC0I5XVeC%2B244dp0SYHZ2cBCZTncpUQSomfKXj1JUR9FMgq%2F7oKLRWKITiRCphCpaUOvkk%2FJB8k2KVcXLS6SuMjob%2F6x4v0cjGaf"}]}
cf-ray: 9b4550474c753e92-BLR
HTTP/2 200
date: Sat, 27 Dec 2025 02:16:03 GMT
content-type: text/html; charset=UTF-8
server: cloudflare
vary: Accept-Encoding
strict-transport-security: max-age=604800
strict-transport-security: max-age=31536000; includeSubDomains
x-content-type-options: nosniff
x-content-type-options: nosniff
x-xss-protection: 1; mode=block
x-xss-protection: 1; mode=block
x-frame-options: SAMEORIGIN
x-frame-options: SAMEORIGIN
content-security-policy: frame-ancestors 'self';
referrer-policy: no-referrer
referrer-policy: strict-origin-when-cross-origin
link: ; rel="https://api.w.org/"
link: ; rel="alternate"; title="JSON"; type="application/json"
link: ; rel=shortlink
fastcgi-cache: HIT
report-to: {"group":"cf-nel","max_age":604800,"endpoints":[{"url":"https://a.nel.cloudflare.com/report/v4?s=fgbirEdjFXuHXv7CHmhy12HuCP6M3SPRzssRMUbR2cRB0RhSjwYXyatbi%2F1cVCTev6w9WsFJz0ObQtJt1x8vrqfAMBDnUEtoJvgi2RMMMWflDNjL"}]}
cf-cache-status: DYNAMIC
nel: {"report_to":"cf-nel","success_fraction":0.0,"max_age":604800}
content-encoding: gzip
cf-ray: 9b45504b39523e92-BLR
gform_form_validation_errors - Gravity Forms Documentation
gform_form_validation_errors
Description
The gform_form_validation_errors filter enables the list of validation errors, which will be displayed at the top of the form, to be overridden.
Usage
add_filter( 'gform_form_validation_errors', 'your_function_name', 10, 2 );
You can also specify this per form by adding the form id after the filter name.
add_filter( 'gform_form_validation_errors_6', 'your_function_name', 10, 2 );
Parameters
- $errors array
An array of field validation errors. The following keys will be defined for each error: field_label, field_selector, and message.
-
$form Form Object
The current form object.
Examples
Add a new error
add_filter( 'gform_form_validation_errors', function ( $errors, $form ) {
$errors[] = array(
'field_label' => 'the field label here',
'field_selector' => '#field_1_10',
'message' => 'the error message here',
);
return $errors;
}, 10, 2 );
Append phone field instruction
add_filter( 'gform_form_validation_errors', function ( $errors, $form ) {
if ( empty( $errors ) ) {
return $errors;
}
foreach ( $errors as &$error ) {
$selector_parts = explode( '_', rgar( $error, 'field_selector' ) );
$field = GFAPI::get_field( $form, rgar( $selector_parts, 2 ) );
if ( $field->get_input_type() !== 'phone' ) {
continue;
}
$phone_format = $field->get_phone_format();
if ( empty( $phone_format['instruction'] ) ) {
continue;
}
$error['message'] .= sprintf( ' Phone format: %s', $phone_format['instruction'] );
}
return $errors;
}, 10, 2 );
Placement
This code should be placed in the functions.php file of your active theme or a custom functions plugin.
Since
This filter was added in Gravity Forms v2.5.
Source Code
This filter is located in GFFormDisplay::get_validation_errors() in form_display.php.