Block Personal Email Addresses on Forms for Marketo



Over the past few months we've had quite a few requests come up around block personal email addresses from forms, and thought that we would share the code. It will essential deliver an error message to the web visitor explaining that they are required to enter a work email address. Feel free to add as many exclusions as you feel are necessary, this can be extended to your competitor domains.

In order to implement the code, you'll have to layer the script listed below on the "Marketo Landing Page Template":

<script type="text/javascript" src="/js/public/jquery-latest.min.js" language="Javascript"></script>
<script type="text/javascript">
    // set no conflict mode for jquery
  var $jQ = jQuery.noConflict();
    //edit this list with the domains you want to block
  var invalidDomains = ["@gmail","@yahoo","@hotmail","@live","@msn","@comcast","noemail","@none","@test","@fuse","@bellsouth","@aim","@mac","@excite","@verizon","@att","@live","@aolmail","@blogger","@ymail","@rogers","@comcast","@37","@gmx","@juno","@inbox","@lycos","@muchomail","@runbox","@rr","@adelphia","@cox","@sbcglobal","@husmail","@rocketmail","@outlook","@aol","@blank"]
  
function formSubmit(elt) {
      // run the custom validation.  If it succeeds, run the Marketo validation
    if (!isEmailGood()) {
       Mkto.setError($jQ("#Email ~ span").prev()[0],"Please provide a business email address.");
       return false;
    } else {
       Mkto.clearError($jQ("#Email ~ span").prev()[0]);
    }
    return Mkto.formSubmit(elt);
  }

  function isEmailGood() {
    for(i=0; i < invalidDomains.length; i++) {
      if ( $jQ("#Email[value*=" + invalidDomains[i] + "]").length > 0) {
          return false;
      }
    }
    return true;
  }
</script> 



Visit us and learn more about digital marketing accelerators and how they can improve your bottom line.

www.marketingfox.net 

Comments