AnsweredAssumed Answered

Adding Script to a Marketo Embed Code

Question asked by dbc8cb02afba9a1fda533cb3e4f467c49abd151b on Jun 12, 2018
Latest reply on Jun 14, 2018 by Jay Jiang

I am using a wordpress page and adding a Marketo embed code. I'd like to restrict the email addresses so that people with a gmail/yahoo address cannot fill out the form. How would I go about adding the script? Would it be on the wordpress page or between the embed code?

(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){
   var email = form.vals().Email;
   if(!isEmailGood(email)) {
   var emailElem = form.getFormElem().find("#Email");
   form.showErrorMessage("Must be Business email.", emailElem);
  function isEmailGood(email) {
   for(var i=0; i < invalidDomains.length; i++) {
   var domain = invalidDomains[i];
   if (email.indexOf(domain) != -1) {
   return false;
   return true;