By Verifying Mail Domain Using Mailcheck
For a demo, enter a@hotmale.com or b@gmail.co in the field below:
Mailcheck offers user-misspelled email address suggestions for second and top level domains. For example, when a user types in "user@hotmail.cmo", "hotmail.com" will be suggested. Similarly, if only the second level domain is misspelled, it will be corrected independently of the top level domain.
Mailcheck is perfect for preventing errors in user signups. Some users claim it has reduced sign up confirmation email bounces by 50%!
How to use Mailcheck in your form
Make sure to include the Mailcheck.js and jQuery.
1 2 |
<script src='https://code.jquery.com/jquery-1.11.0.min.js'></script>") <script src="https://cdnjs.cloudflare.com/ajax/libs/mailcheck/1.1.2/mailcheck.js"></script> |
Add the form elements. The "hint" element is a hidden div that will contain email suggestions to the user.
1 2 3 |
<input id="email" name="email" type="email" /> <input name="Submit" type="submit" /> <p id="hint"></p> |
Set up the basic JavaScript structure by attaching the mailcheck() function to the email field blur event, which is called whenever the element loses focus.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
var email = jQuery('#email'); var hint = jQuery("#hint"); email.on('blur',function() { hint.css('display', 'none').empty(); // hide hint initially jQuery(this).mailcheck({ suggested: function(element, suggestion) { if(!hint.html()) { // misspell - display hint element var suggestion = "Did you mean <span class='suggestion'>" + "<span class='address'>" + suggestion.address + "</span>" + "@<a href='#' class='domain'>" + suggestion.domain + "</a></span>?"; hint.html(suggestion).fadeIn(150); } else { // Subsequent errors jQuery(".address").html(suggestion.address); jQuery(".domain").html(suggestion.domain); } } }); }); hint.on('click', '.domain', function() { // Display with the suggestion and remove the hint email.val(jQuery(".suggestion").text()); hint.fadeOut(200, function() { jQuery(this).empty(); }); return false; }); |
The Mailcheck defaults to a list of top email domains if the domain option isn’t provided. The list of default domains are: yahoo.com, google.com, hotmail.com, gmail.com, me.com, aol.com, mac.com, live.com, comcast.net, googlemail.com, msn.com, hotmail.co.uk, yahoo.co.uk, facebook.com, verizon.net, sbcglobal.net, att.net, gmx.com, and mail.com.