PHP, Wordpress

Customizing Gravity Form’s Validation Error Message

When the user did not put anything on a required field on a Gravity Forms form, they will get the standard validation error from the plugin:

Gravity Forms Default Validation Error Message

“There was a problem with your submission. Errors have been highlighted below.”

Most would want to customize this message to their own liking. To do this, we need to add a filter code on the themes functions.php file. Open your theme’s function.php file and start adding the following code:

//Change Gravity Forms Validation Error Message
add_filter("gform_validation_message", "gf_validation_msg", 10, 2);
	function gf_validation_msg($message, $form){
	return '
		<div class="validation_error">This is the custom message that I want as my validation error.</div>
	';
}

Result:

Custom Gravity Forms Default Validation Error Message


Bonus: If you want to futher customize your validation error message, you can add css styles on the class css class below:

.gform_wrapper div.validation_error {
	color: #3800ff !important;
	font-size: 24px!important;
	border: 1px solid #3800ff !important;
}