SOLVED

Limit Email Domains on Form Submission

Go to solution
Hiram_Cruz
Level 2

Re: Limit Email Domains on Form Submission

Hi group, 

I'm trying to embed a form on a non-marketo LP with the javascript from this thread to exclude gmails & yahoo's ect.

I copy + pasted Egnet's code but can't get the form to render. Can someone please help point out what I'm doing wrong here? 

Here's my script: 



<script src="//learn.cpcstrategy.com/js/forms2/js/forms2.js"></script>
<form id="mktoForm_1200"></form>
<script>MktoForms2.loadForm("//learn.cpcstrategy.com", "006-GWW-889", 1200, function(form){
 
form.onValidate(function(valid) {
var email = form.getFormElem().find("#Email");
 
var validateEmail = function(email) {
var filters = [
"123mail","aol","att","bellsouth","charter","comcast","cox","earthlink","gmail","gmx","gmx","googlemail","hotmail","juno","live","mac","mail","me","mindspring","msn","optonline","pacbell","rediffmail","rocketmail","rogers","rr","sbcglobal","sympatico","telus","verizon","web","yahoo","ymail","zigmail","bigstring","bumpymail","centermail","centermail","discardmail","dodgeit","e4ward","emailias","fakeinformation","front14.","getairmail","ghosttexter","jetable","kasmail","link2mail","mailexpire","mailinator","mailmetrash","mailmoat","messagebeamer","mytrashmail","nepwk","nervmich","netmails","netzidiot","nurfuerspam","oneoffemail","pookmail","privacy","punkass","rmqkr","sharklasers","sneakemail","sofortmail","sogetthis","spam","spambob","spambob","spambob","spambog","spamex","spamgourmet","spamhole","spaminator","spammotel","spamtrail","trash-mail","trashymail","trashmail","yopmail","wuzup"
],
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>
 





Anonymous
Not applicable

Re: Limit Email Domains on Form Submission

This code works great, but is there a way to edit it so that the button is red instead of blue?
Jason_Scott
Level 4

Re: Limit Email Domains on Form Submission

You can edit button when building the form in Marketo.