Customize Invalid Email Error Message [RESOLVED]

Is there a way to customize/edit the default validation error message for the email field when an invalid address is entered?

image

You can customize the validation error in the field settings, example: Screenshot IMEVUpqvQq.png - Droplr

Result: Screenshot A3agtEkp5Z.png - Droplr

Samuel,

Thanks for your reply, and I am aware of the ability to override the default validation message with a custom text as pictured below, however, this overrides the validation message displayed for both an empty field and an invalid email address format.

image

(Gonna have to do this in multiple replies)

If the field is empty, I would like to keep the default validation message as pictured below.

image

I’d really like to customize the validation message specific to an invalid email address format, namely I’d like to change this from (e.g. email@domain.com) to our example organization email address.

image

Then you will need to use the gform_field_validation filter and some custom PHP code. Example:

add_filter( 'gform_field_validation', function ( $result, $value, $form, $field ) {
	if ( ! $result['is_valid'] && $field->get_input_type() === 'email' && 'The email address entered is invalid, please check the formatting (e.g. email@domain.com).' == $result['message'] ){
		$result['message']  = 'Custom validation message here.';
	}
	return $result;
}, 10, 4 );

Precisely what I needed, thank you for your assistance Samuel!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.