Re: How do I require a BUSINESS email (and reject form fills using gmail or yahoo email addresses fo

Anonymous
Not applicable

How do I require a BUSINESS email (and reject form fills using gmail or yahoo email addresses for the required email)

I need a quick answer on how to require a business email. How do I set up this logic in my form fill?

10 REPLIES 10
Anonymous
Not applicable

Re: How do I require a BUSINESS email (and reject form fills using gmail or yahoo email addresses for the required email)

Add this piece of javascript code to your page

<script>
(function (){
  // Please include the email domains you would like to block in this list
  var invalidDomains = ["@gmail.","@yahoo.","@hotmail.","@live.","@aol.","@outlook."];
  MktoForms2.whenReady(function (form){
   form.onValidate(function(){
   var email = form.vals().Email;
   if(email){
   if(!isEmailGood(email)) {
   form.submitable(false);
   var emailElem = form.getFormElem().find("#Email");
   form.showErrorMessage("Must be Business email.", emailElem);
  }else{
   form.submitable(true);
  }
  }
  });
  });
 
  function isEmailGood(email) {
   for(var i=0; i < invalidDomains.length; i++) {
   var domain = invalidDomains[i];
   if (email.indexOf(domain) != -1) {
   return false;
  }
  }
   return true;
  }
})();
</script>
Josh_Hill13
Level 10 - Champion Alumni

Re: How do I require a BUSINESS email (and reject form fills using gmail or yahoo email addresses for the required email)

cool.

Keep in mind this is a common question and if you search, there are a lot of answers. Your web dev can do this for you.

Grégoire_Miche2
Level 10

Re: How do I require a BUSINESS email (and reject form fills using gmail or yahoo email addresses for the required email)

Hi Jenna,

That's nice of you to provide the code.

You may want to add a few other domains there, as you are only covering the most common and US centric. Other countries may have other ISP's will very common domains. e.g. orange.fr, lapposte.net in France.

-Gretg

SanfordWhiteman
Level 10 - Community Moderator

Re: How do I require a BUSINESS email (and reject form fills using gmail or yahoo email addresses for the required email)

You may want to add a few other domains there, as you are only covering the most common and US centric. Other countries may have other ISP's will very common domains. e.g. orange.fr, lapposte.net in France.

The authoritative list is the Freemail list.

I find this approach needlessly draconian in most cases.  I tend to skip forms that will not allow me to evaluate business software using a non-business address.  Many industries have mail retention rules (and still more companies have non-private mailboxes) and sales inquiries can often have a private aspect. Demanding a "business" address.isn't the proper model for every customer journey, even if it works for the vast majority.

Anonymous
Not applicable

Re: How do I require a BUSINESS email (and reject form fills using gmail or yahoo email addresses for the required email)

Thanks for posting this list!

Marit_Rossing
Level 3

Re: How do I require a BUSINESS email (and reject form fills using gmail or yahoo email addresses for the required email)

Where do you place this piece of code on a Marketo Landing Page?

I have placed it at the 'Custom Head HTML' in 'Edit page meta tags' but this doesn't work. I can only add this code in the landing page template?

Bobby_Riegel4
Level 1

Re: How do I require a BUSINESS email (and reject form fills using gmail or yahoo email addresses fo

Is this code still valid? I've added it to the template, but it does not stop the form from submitting. 

Jake_Nelson
Level 2

Re: How do I require a BUSINESS email (and reject form fills using gmail or yahoo email addresses for the required email)

Is there a way to prevent people from putting in random information, such as "ABC" for "123" for any of the fields?

SanfordWhiteman
Level 10 - Community Moderator

Re: How do I require a BUSINESS email (and reject form fills using gmail or yahoo email addresses for the required email)

Neither of those strings are "random" in a company name, street address, or postal code.  In a first or last name, probably.  But just because someone fills in fake first/last name data doesn't mean they are a fake lead.  If you're really concerned about this, you can filter anything you want using Forms 2.0 JS. I'd caution, as with the freemail topic, that you end up grabbing a few low-hanging fruits and have a false sense that everything else is somehow legit (even though there are thousands of freemail providers).