Open Source Business Email Validator By Loginradius

First published: 2017-04-25      |      Last updated: 2025-06-25

While 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. Gmail.com, Yahoo.com, Yahoomail.com, Rediff.com 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

    1<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
  • Call json file content in a script variable like

1<script>
2    var emailValidator = {
3        "123.com": true,
4        "123box.net": true,
5        "123india.com": true,
6        …………………….
7        …………………..
8        "ymail.com": true,
9        "yandex.com": true
10    };
11</script>

Our complete list is available here

  • Add validation form function after you have added above code.
1<script>
2function validateForm(id) {
3                            var emailValue = jQuery('#'+id).val();
4                            var emailArray = emailValue.split("@");
5                            var provider = emailArray[1] ? emailArray[1] : '';
6                            for(var domain in emailValidator){
7                            if(emailValidator[domain]){
8                                                        if(domain == provider){
9                                                        alert("Please Provide Business Email Address.");
10                                                        return false;
11                                                                        }
12                                                      }
13                           }
14 return true;
15}
16</script>
  • Create html form

 

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

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.

1<?php
2$email = isset($_POST[‘email’]) ? trim($_POST[‘email’]):’’;
3if(!empty($email)){
4                 $tempEmail = explode('@', $email);
5                     if (isset($tempEmail['1']) && !empty($tempEmail['1'])) {
6                 $validEmail = json_decode(file_get_contents('freeEmailService.json'), true);
7                     if (is_array($validEmail) && in_array($tempEmail['1'], array_keys($validEmail))) {
8                     echo "Please use business email address.";
9                  }
10                }
11}else{
12                     echo ‘email is required field.’;
13}
14?>
  • 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.

Team LoginRadius
By Team LoginRadiusLoginRadius is a leading provider of cloud-based Customer Identity and Access Management (cIAM) platform.
cardImage

The State of Consumer Digital ID 2024

cardImage

Top CIAM Platform 2024

cardImage

Learn How to Master Digital Trust

Customer Identity, Simplified.

No Complexity. No Limits.
Thousands of businesses trust LoginRadius for reliable customer identity. Easy to integrate, effortless to scale.

See how simple identity management can be. Start today!