Engineering Blog

Open Source Business Email Validator By Loginradius

Open Source Business Validator By LoginradiusWhile creating Lead Generation form at LoginRadius, Marketers wanted to sure that visitors enter business emails. To that end, I created a list in JSON format to block free mail providers like Gmail, Outlook etc.

Business mail validator makes sure users enters only business emails in submission forms on a web page. User can’t enter with free email’s that provided by the third party (free email) service provider.

Ex.,,, etc.

We can classified business email validation in two ways.

1. Client side

In client side validation we use javascript(js) OR jQuery to validate entered the email at time of submission the html form. So we can follow the following steps to validate it on client side.

  • First of all create a simple html page with name emailvalidate.html
  • Add jQuery script on head section
    <script src=""></script>
  • Call json file content in a script variable like
	var emailValidator = { 
               "": true,
               "": true, 
               "": true,
               "": true, 
               "": true 

Our complete list is available here

  • Add validation form function after you have added above code.
function validateForm(id) { 
                            var emailValue = jQuery('#'+id).val(); 
                            var emailArray = emailValue.split("@"); 
                            var provider = emailArray[1] ? emailArray[1] : ''; 
                            for(var domain in emailValidator){
                                                        if(domain == provider){ 
                                                        alert("Please Provide Business Email Address."); 
                                                        return false;
 return true; 
  • Create html form


<form name="myForm" action="emailsubmit.php" onsubmit="return validateForm('business_email');" method="post">
<input type="text" placeholder="Full Name"/><br> 
<input type="email" id="business_email" name="email" placeholder="Email Address"/><br> 
<input type="submit" value="submit"/>

Note: if you have already have html form where you want to apply this avalidator, look up for the buysiness_email and replace it accordingly.

  • Save the file and try to execute this html page on a browser.

2. Server side

In Server side validation we use php scripting language to validate entered email at time of submission the html form. So we can flow the following steps to validate it.

  • Create a php page with name of emailsubmit.php
  • Receive email in php post method by following code.
$email = isset($_POST[‘email’]) ? trim($_POST[‘email’]):’’;
	             $tempEmail = explode('@', $email); 
                     if (isset($tempEmail['1']) && !empty($tempEmail['1'])) {
 	             $validEmail = json_decode(file_get_contents('freeEmailService.json'), true);
                     if (is_array($validEmail) && in_array($tempEmail['1'], array_keys($validEmail))) {
                     echo "Please use business email address."; 
                     echo ‘email is required field.’;
  • Save file and upload on server

Feel free to add, edit or modify this script as per your requirements. You can contact us if you have any queries.

Related Posts