I am working with drupal8 site.Here i want to override the default "The email address %mail is not valid" email format validation message.I have checked with hook_form_alter to implement this.But no result.Is it possible to alter this message?

2 Answers 2


For Drupal 8, Webform uses Drupal's default Email Form Element. You'll have to override this element info and add your own validation message there.

See https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Render%21theme.api.php/function/hook_element_info_alter/8.5.x


I would prefer creating a new webform handler which has custom validation for a specific field instead of using form alter.

I have created a gist for you place it to the correct folder (mymoduleName/src/Plugin/WebformHandler) clear cache and than attach the webform handler to your webform.


Second is, that you create a new webform element which extends WebformEmailMultiple and overriding validateWebformEmailMultiple function(you can just copy paste it and change the text). But you will have to add a new webform element in webform.

I hope it can help you!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.