How do I require a BUSINESS email (and reject form fills using gmail or yahoo email addresses for the required email) | Community
Skip to main content
Mar 3, 2016 5:33 PM UTC
Question

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?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

10 replies

Level 2
Mar 10, 2016 4:48 PM UTC

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

Translate
SanfordWhiteman
Level 10
Mar 10, 2016 6:34 PM UTC

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).

Translate
Mar 3, 2016 6:36 PM UTC

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>
Translate
Josh_Hill13
Level 10
Mar 3, 2016 11:11 PM UTC

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.

Translate