In the magical land of B2B marketing, it’s significantly more valuable to capture business email addresses than personal ones.

There are multiple reasons for this:

  1. You gain insight into who your leads are
  2. You can easily validate the quality of leads generated
  3. You can do specific outreach to their business via retargeting, social, calls, etc.

You probably already know that.

Here’s how to do it

Anyways, assuming you have a web form on a page (even if it’s a form builder tool like Unbounce, Hubspot, Pardot, InfusionSoft, etc.) this will work in most cases. Simply paste the following javascript codes into the header of your page.

<script src=”//ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js” type=”text/javascript”></script>

<script>

$(document).ready(function(e){

$(‘#PUT-ID-OF-BUTTOM-THAT-GETS-CLICKED-HERE’).click(function(){

var email = $(‘#PUT-ID-OF-EMAIL-FIELD-HERE’).val();

var reg = /^([\w-\.]+@(?!gmail.com)(?!yahoo.com)(?!hotmail.com)(?!yahoo.co.in)(?!aol.com)(?!abc.com)(?!xyz.com)(?!pqr.com)(?!rediffmail.com)(?!live.com)(?!outlook.com)(?!me.com)(?!msn.com)(?!ymail.com)([\w-]+\.)+[\w-]{2,4})?$/;

if (reg.test(email)){

return 0;

}

else{

alert(‘Please Enter Business Email Address’);

return false;

}

});

});

</script>

A few things to note

The first script of the two above is actually just referencing a module that is required for the second one to function correctly.

In the second script, there are two highlighted, capitalized sections that require you to swap out the ID’s of your button and email field so that it functions correctly. If you’re not familiar with what those are, you can learn more about ID selectors here.

Also in the second script, you’ll see where personal email clients like “gmail” and “yahoo” are referenced. You can add more of those in there as needed.

Finally, if the script is working correctly, if you try and submit the form with one of the excluded personal email types, the browser should reject the form fill and reply with the message “We’re sorry, the form could not be submitted. Please try again.” to the user.