SOLVED

Re: Limit Email Domains on Form Submission

Go to solution
Halid_Delkic
Level 3

Re: Limit Email Domains on Form Submission

Works for me. Kathi, thanks very much for sharing. 
Anonymous
Not applicable

Re: Limit Email Domains on Form Submission

I've included an updated list of the most common personal, ISP and free email domains below. You can substitue the longer list for this short list in the example above:

"hotmail.com",
"yahoo.com",
"aol.com",
"gmail.com",

You can also find an extensive list (more than 3,500 as of this writing) at https://gist.github.com/tbrianjones/5992856

Most common personal, ISP and free email domains:

"123mail.org",
"aol.com",
"att.net",
"bellsouth.net",
"bigstring.com",
"blueyonder.co.uk",
"bt.com",
"btinternet.com",
"bumpymail.com",
"centermail.com",
"centermail.net",
"charter.net",
"comcast.net",
"cox.net",
"discardmail.com",
"dodgeit.com",
"e4ward.com",
"earthlink.net",
"email.com",
"emailias.com",
"facebook.com",
"fakeinformation.com",
"freeserve.co.uk",
"front14.org",
"games.com",
"getairmail.com",
"ghosttexter.de",
"gmail.com",
"gmx.com",
"gmx.de",
"gmx.net",
"google.com",
"googlemail.com",
"hotmail.co.uk",
"hotmail.com",
"hush.com",
"hushmail.com",
"inbox.com",
"jetable.net",
"juno.com",
"kasmail.com",
"lavabit.com",
"link2mail.net",
"live.co.uk",
"live.com",
"love.com",
"mac.com",
"mail.com",
"mailexpire.com",
"mailinator.com",
"mailmetrash.com",
"mailmoat.com",
"me.com",
"messagebeamer.de",
"mindspring.com",
"msn.com",
"mytrashmail.com",
"nepwk.com",
"nervmich.net",
"netmails.net",
"netzidiot.de",
"ntlworld.com",
"nurfuerspam.de",
"o2.co.uk",
"oneoffemail.com",
"optonline.net",
"orange.net",
"outlook.com",
"pacbell.net",
"pobox.com",
"pookmail.com",
"privacy.net",
"punkass.com",
"rediffmail.com",
"rmqkr.net",
"rocketmail.com",
"rogers.com",
"rr.com",
"safe-mail.net",
"sbcglobal.net",
"sharklasers.com",
"sky.com",
"sneakemail.com",
"sofort-mail.de",
"sogetthis.com",
"spam.la",
"spambob.com",
"spambob.net",
"spambob.org",
"spambog.com",
"spamex.com",
"spamgourmet.com",
"spamhole.com",
"spaminator.de",
"spammotel.com",
"spamtrail.com",
"sympatico.ca",
"talktalk.co.uk",
"telus.net",
"tiscali.co.uk",
"trash-mail.de",
"trashmail.net",
"trashymail.com",
"verizon.net",
"virgin.net",
"virginmedia.com",
"wanadoo.co.uk",
"wow.com",
"wuzup.net",
"yahoo.co.uk",
"yahoo.com",
"ygm.com",
"ymail.com",
"yopmail.com",
"zigmail.com",
"zoho.com",
Jon_Jagelsky
Level 2

Re: Limit Email Domains on Form Submission

Has anyone else found that this code does not work on IE 9 and below? Works fine in IE 10 & 11 but won't allow form submit no matter what the email address is in IE 9.

Was also wondering if anyone has altered the Marketo supplied script for form validation (#9 on here -http://developers.marketo.com/documentation/websites/forms-2-0/)  to work for Email address and would care to share. I haven't seen it out in the Community yet. Time to go brush up on my js knowledge...

  1. MktoForms2.loadForm("//app-sjqe.marketo.com", "718-GIV-198", 621, function(form){
  2.   //listen for the submit event
  3.   form.onSubmit(function(){
  4.     //get the values
  5.     var vals = form.getValues();
  6.     //Check your condition
  7.     if(vals.Country == "USA"&& vals.VehicleSize != "massive"){
  8.       //prevent form submission
  9.       form.submitable(false);
  10.       //Show error message, pointed at VehicleSize element
  11.       var vehicleSizeElem = form.getFormElem().find("#VehicleSize");
  12.       form.showErrorMessage("All Americans must have a massive vehicle", vehicleSizeElem);
  13.     }else{
  14.       //enable submission for those who met the criteria.
  15.       form.submitable(true);
  16.     }
  17.   });
  18. });
Enget_Dang
Level 3

Re: Limit Email Domains on Form Submission

I've had trouble with this script from IE as well. Caused some big headaches when attendees were trying to register for a webinar and couldn't submit their information.

Worked with our web developer to get this script working. Feel free to try and test. Used BrowserStack to test across browsers using the Marketo embed script. Insert after loadForm line:
 

form.onValidate(function(valid) {
var email = form.getFormElem().find("#Email");
 
var validateEmail = function(email) {
var filters = [
"gmail", "yahoo"
],
domain = email.substring(email.indexOf('@') + 1),
parts = domain.split('.');
 
for(var filter in filters) {
for(var i = 0, ln = parts.length; i < ln; i++) {
if(parts[i].toLowerCase() == filters[filter]) {
return false;
}
}
}
return true;
};
 
if(validateEmail(email.val())) {
form.submitable(true);
} else {
form.submitable(false);
form.showErrorMessage("Please provide a company email address.", email);
}
});
 
});</script>
Enget_Dang
Level 3

Re: Limit Email Domains on Form Submission

Also, this is not an April Fool's joke 😉
Jon_Jagelsky
Level 2

Re: Limit Email Domains on Form Submission

Hi Enget,

Thanks for sharing your code! I finally got around to testing last week and it worked as expected when embedding the form. I'm curious if you've had any success using this when placing the form directly on a Marketo LP? and how you got it to work? I tried using it with the drag and drop form and the script was causing the form to load twice on the page.

The problem is when using this and embeding the form I've lost the prefill functionality. 

I hate to gain one functionality but lose another. Would love to hear your thoughts.

Thanks!
Jason_Scott
Level 4

Re: Limit Email Domains on Form Submission

Jon or Enget,

Would either one of you be willing to share a live page with this script?

Thanks!
Jason
Enget_Dang
Level 3

Re: Limit Email Domains on Form Submission

Hi Jon and Jason,

I haven't been able to get the script to work on a Marketo LP, only as an embedded form on a web page. Currently working on a solution to get it resolved on Marketo LPs. Jon, here is the form we are using with the current script: http://www.boaweb.com/contact-us/ 

Thanks!

Enget
Jason_Scott
Level 4

Re: Limit Email Domains on Form Submission

Thanks Enget!
Anonymous
Not applicable

Re: Limit Email Domains on Form Submission

Has anyone had an issue with getting the form.showErrorMessage() to persist when users hit the ENTER key instead of the submit button?

For us, when users uses the ENTER key to submit the form, the message is rendered but quickly, but quickly disappears.  If the user clicks the SUBMIT button, the error message persists until the user edits the input box (correct behavior).

Any ideas how to make the ENTER key and SUBMIT button behave the same?

We've tested this only on a Mac, but same behavior exists in Safari, Firefox and Chrome.