AnsweredAssumed Answered

Require Business Email Address on Forms

Question asked by Trevor Parsell on Jan 18, 2018
Latest reply on Jul 29, 2019 by Sanford Whiteman

Hello,

 

I found the script below in this discussion: How do I require a BUSINESS email

 

I pasted the script in my Marketo landing page template and tested the form with a Yahoo email address and it still is allowing me to submit the form. Where exactly should this script be placed to reject non-business email addresses for particular forms? Any help would be greatly appreciated.

 

<script>
(function (){
  // Please include the email domains you would like to block in this list
  var invalidDomains = ["@yahoo.","@hotmail.","@live.","@aol.","@msn.","@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>

 



Thanks!

Trevor

Outcomes