Email validation to catch typos


#1

Many people who enter an email address on my forms are including obvious typos in the domain of their email. For example, john@gamil.com, jane@yaho.com, frank@hotmail.con, etc. Because they follow the correct syntax for emails, they are not caught by the default validation for email addresses.

Is there a way for us to catch these? For example, can we use some code to create a list of popular misspellings of domains, and reject them?


#2

Interested!


#3

Hi guys, 

Depending on how comfortable you are with writing scripts, you should be able to accomplish your desired goal with a bit of javascript/jquery. 

Here are a few links for inspiration: 

  1. Here is a way to exclude free email providers, which in theory you can modify to reject misspelled domains.

  2. A more elegant solution, which requires a bit more tinkering with javascript. 

Hope this points you in the right direction. 

Best,
Hristian


#4

Hi Andy,

I use Data 8 domain validation for a client on an Unbounce landing page. Please check the link below.

https://www.data-8.co.uk/services/data-validation/validation-services/email-validation

This works well to ensure we get good quality data from our form submissions. 

Hope that helps a little,

Cheers

Stuart.


#5

Hey Stuart, 

Awesome tip as data validation is always better with a service that actually checks if the domain exists, etc.

Definitely worth it if the budget/requirements allow for it.

Best,
Hristian 


#6

Thank you very much! We’ll try these out, and let you know how it goes.


#7

Hi Stuart,

Can you post a sample code of you how managed to get Data-8 Validation working with Unbounce.

I almost got it working thanks to the sample code posted here (http://www.howtobuildsoftware.com/index.php/how-do/Y1s/“) but still can’t get Unbounce to react properly on the response I get from Data-8 service.

Regards,
Nikolay


#8

Using the Unbounce Custom Validation Script from this page and script posted on Stackoverflow regarding Data-8 Validation I almost got it working but my problem is that the Unbounce Custom Validation script does not wait for the response of the IsValid function once it is being called but always returns “undefined”. How can I make it wait for the response (true or false) of the function.

The exact code that I use to setup the Data-8 Function is:



<script type="text/javascript">
 
function loadIntegr8() {
  // Load the InternationalTelephoneValidation Integr8 service
  data8.load('InternationalTelephoneValidation');
}
 
var funReady;

function IsValid(telephoneNumber, defaultCountry) {
  funReady = new $.Deferred();
  var internationaltelephonevalidation = new data8.internationaltelephonevalidation();
  internationaltelephonevalidation.isvalid(
    telephoneNumber,
    defaultCountry,
    [
      new data8.option('UseMobileValidation', 'true'),
      new data8.option('UseLineValidation', 'true')
    ],
    showIsValidResult
  );


           $.when(funReady).then(function() {
         console.log (funReady.state());
    return funReady.state() === "resolved" ? true : false;

       });


 

}


function showIsValidResult(result) {
  if (!result.Status.Success) { // http(s) request failed
    funReady.reject();
  }

  if(result.Result.ValidationResult == "Invalid") {
    funReady.reject();
  } else {
    funReady.resolve();
  }
}

loadIntegr8();
  
  
 
</script>

And the code used for the Unbounce Custom Validation is:

<script type="text/javascript">
  
  lp.jQuery(function($) {
  
    // Config
    var ruleID = 'myCustomRule';
    var field = 'phone_number';
    var message = 'Invalid UK Phone Number';
  
    var rules = module.lp.form.data.validationRules[field];
  
    $.validator.addMethod(ruleID, function(value, field) {
  
      // Replace this with any expression you like. It should evaluate to true
      // if the field is valid and false if invalid. This example adds a 
      // rule that the user must enter 'I accept' exactly into the field.
            var valid = IsValid(value, 'GB');
    
   


     

      return valid || (!rules.required && !value); 
      
    }, message);
  
    rules[ruleID] = false;
  
  });
</script>