CARVIEW |
Select Language
HTTP/2 200
date: Mon, 13 Oct 2025 05:31:33 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
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=Il1jU3kSfuvmrv%2BDo7kIIwwLFXnrmPfqEPGExGnoSiRN4vRxQzAmQCB%2FlvNfY0ZOOtXOO%2BeO2liaE2udCHqIdn%2FaWflWQjpnyRrcw3n3zswDu7mk"}]}
cf-cache-status: DYNAMIC
nel: {"report_to":"cf-nel","success_fraction":0.0,"max_age":604800}
content-encoding: gzip
cf-ray: 98dc73857a1accbb-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.