How to prevent common email typos

Sometimes you want to show an error if a user types in (instead of

Use the Custom JavaScript below to detect common email typos and show an error message to the user. We run this in Box JS After Form Validation to add additional validation on top of the basic validation already configured for your forms. For more information on the form processing pipeline, see Custom JS Overview for Developers.

Custom JS Boxes – Event Trigger “After Form Validation”

var wrongMails = ["Gogglemail", "googlmail", "goglemail", "Hotmial", "Hotmal", "Hoitmail", "Homail", "Hotnail", "Hotrmail", "Hotmil", "Hotmaill", "Ntlwolrd", "ntlword", "", "ntlwrold", "Tiscale", "tiscalli", "Tiscally", "Tiscaly", "Btinterent", "btinternt", "Yaho.", "Uahoo", "ayhoo", "ymial", "ymal", "ymil", "ymaill", "ynail", "yail", "gmial", "gmal", "gmil", "gnail", "gmaill", "gail"];

var email =;
var isValid = true;

   if(email) {
      var emailDomain = email.split("@")[1].toLowerCase();
      if(emailDomain.includes(mail.toLowerCase())) {
         isValid = false;

if(!isValid) {
   showError("please enter a valid email address");
   return false;