I need a quick answer on how to require a business email. How do I set up this logic in my form fill?
Add this piece of javascript code to your page
<script> | |
(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){ | |
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> |
cool.
Keep in mind this is a common question and if you search, there are a lot of answers. Your web dev can do this for you.
Hi Jenna,
That's nice of you to provide the code.
You may want to add a few other domains there, as you are only covering the most common and US centric. Other countries may have other ISP's will very common domains. e.g. orange.fr, lapposte.net in France.
-Gretg
You may want to add a few other domains there, as you are only covering the most common and US centric. Other countries may have other ISP's will very common domains. e.g. orange.fr, lapposte.net in France.
The authoritative list is the Freemail list.
I find this approach needlessly draconian in most cases. I tend to skip forms that will not allow me to evaluate business software using a non-business address. Many industries have mail retention rules (and still more companies have non-private mailboxes) and sales inquiries can often have a private aspect. Demanding a "business" address.isn't the proper model for every customer journey, even if it works for the vast majority.
Thanks for posting this list!
Where do you place this piece of code on a Marketo Landing Page?
I have placed it at the 'Custom Head HTML' in 'Edit page meta tags' but this doesn't work. I can only add this code in the landing page template?
Is this code still valid? I've added it to the template, but it does not stop the form from submitting.
Is there a way to prevent people from putting in random information, such as "ABC" for "123" for any of the fields?
Neither of those strings are "random" in a company name, street address, or postal code. In a first or last name, probably. But just because someone fills in fake first/last name data doesn't mean they are a fake lead. If you're really concerned about this, you can filter anything you want using Forms 2.0 JS. I'd caution, as with the freemail topic, that you end up grabbing a few low-hanging fruits and have a false sense that everything else is somehow legit (even though there are thousands of freemail providers).