Download
User Rating: 4.3/5 ( 2 votes)
Mailcheck.js is a Javascript library and jQuery plugin that suggests a right domain when your users misspell it in an email address.
What does it do?
When your user types in "[email protected]", Mailcheck will suggest "[email protected]".
Mailcheck will offer up suggestions for top level domains too, and suggest ".com" when a user types in "[email protected]".
At Kicksend, we use Mailcheck to help reduce typos in email addresses during sign ups. It has reduced our sign up confirmation email bounces by 50%.
Source: github.com
1. INCLUDE JS FILES
<script src="jquery.min.js"></script>
<script src="mailcheck.min.js"></script>
2. HTML
<input id="email" name="email" type="email" />
3. JAVASCRIPT
var domains = ['hotmail.com', 'gmail.com', 'aol.com'];
var topLevelDomains = ["com", "net", "org"];
var superStringDistance = function(string1, string2) {
// a string distance algorithm of your choosing
}
$('#email').on('blur', function() {
$(this).mailcheck({
domains: domains, // optional
topLevelDomains: topLevelDomains, // optional
distanceFunction: superStringDistance, // optional
suggested: function(element, suggestion) {
// callback code
},
empty: function(element) {
// callback code
}
});
});
Mailcheck takes in two callbacks, suggested and empty. We recommend you supply both.
suggested is called when there's a suggestion. Mailcheck passes in the target element and the suggestion. The suggestion is an object with the following members:
{
address: 'test', // the address; part before the @ sign
domain: 'hotmail.com', // the suggested domain
topLevelDomain: 'com', // the suggested top level domain
full: '[email protected]' // the full suggested email
}
Mailcheck does not want to get in the way of how you can show suggestions. Use the suggestion object to display suggestions in your preferred manner.
empty is called when there's no suggestion. Mailcheck just passes in the target element. It is a good idea to use this callback to clear an existing suggestion.