| CARVIEW |
Select Language
HTTP/2 301
date: Sun, 28 Dec 2025 02:14:42 GMT
content-type: text/html; charset=UTF-8
location: https://docs.gravityforms.com/gform_validation_message/
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: HIT
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=WD1CM9ps4FQvx1EynXyQFAHv70722pcfZNW49lGTPiPnsq5enrk4B66lJnWvFZ%2BPB%2F3E45lZjHpPkl4We98bWyYFbcMV7tct3DLLXHzZMfz12Gb9"}]}
cf-ray: 9b4d8bb0385ddfa6-BLR
HTTP/2 200
date: Sun, 28 Dec 2025 02:14:43 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=XXCIcshJbpwg6DEqt1IzjYpnbCd%2F7%2FiMOPJ8wyM9dD2l5H4juGQkz1zaD2I%2BpBlTpucRcLWQHirKdDl8minb%2BfoJlnsjOHCI3zRV9LVFgg2o0yQY"}]}
cf-cache-status: DYNAMIC
nel: {"report_to":"cf-nel","success_fraction":0.0,"max_age":604800}
content-encoding: gzip
cf-ray: 9b4d8bb51c36dfa6-BLR
gform_validation_message - Gravity Forms Documentation
gform_validation_message
Description
This filter is executed when a form fails validation, before the validation message is displayed. Use this filter to change the default validation message.
Usage
Applies to all forms.
add_filter( 'gform_validation_message', 'your_function_name', 10, 2 );
To limit the scope of your function to a specific form, append the form id to the end of the hook name. (format: gform_validation_message_FORMID)
add_filter( 'gform_validation_message_5', 'your_function_name', 10, 2 );
Parameters
- $message string
The validation message to be filtered.
"<div class='validation_error'>" . esc_html__( 'There was a problem with your submission.', 'gravityforms' ) . ' ' . esc_html__( 'Errors have been highlighted below.', 'gravityforms' ) . '</div>'
-
$form Form Object
The current form.
Examples
1. Include form title in message
This example uses the gform_validation_message filter to change the default validation message.
add_filter( 'gform_validation_message', 'change_message', 10, 2 );
function change_message( $message, $form ) {
return "<div class='validation_error'>Failed Validation - " . $form['title'] . '</div>';
}
2. Include field validation errors
add_filter( 'gform_validation_message', function ( $message, $form ) {
if ( gf_upgrade()->get_submissions_block() ) {
return $message;
}
$message = "<div class='validation_error'><p>There was a problem with your submission. Errors have been highlighted below.</p>";
$message .= '<ul>';
foreach ( $form['fields'] as $field ) {
if ( $field->failed_validation ) {
$message .= sprintf( '<li>%s - %s</li>', GFCommon::get_label( $field ), $field->validation_message );
}
}
$message .= '</ul></div>';
return $message;
}, 10, 2 );
Placement
This code should be placed in the functions.php file of your active theme.
Source Code
This filter is located in GFFormDisplay::get_form() in form_display.php.