Tag Archives: validate

JavaScript – Block email domain

Do you have forms on your website for people to submit sales information? Do you get personal email addresses when you’re looking for business email addresses? Blocking the personal email addresses can be very advantageous to your sales process and can provide a much needed filter on the leads coming in.

Here’s a nice JavaScript function that validates the domain of an email address against a list of predefined blacklisted domains. You add more domains simply add another item to domarray.   For instance you could have:

domarray[3] = “microsoft.”;

Additionally you can validate the domains as specific as possible:

domarray[3] = “gmail.jp”;
domarray[4] = “gmail.co.uk”;
domarray[5] = “gmail.kr”;

The Whole Script

function chckDomain(em) {
var emat = em.substring(0,em.lastIndexOf(‘@’)+1);
var emdom = em.substring(emat.length,em.length+1);
var emdom = emdom.toLowerCase();
var domarray = Array();
domarray[0] = “gmail.”;
domarray[1] = “hotmail.”;
domarray[2] = “yahoo.”;
for (i=0; i < domarray.length ; i++) {
if (emdom.indexOf(domarray[i]) != -1) {
return false;
return true;