A MooTools plugin that suggests a right domain when your users misspell it in an email address using Levenshtein Distance.
JavaScript
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
Demos
Docs
Source
README.md
package.yml

README.md

mailcheck.js

A MooTools plugin that suggests a right domain when your users misspell it in an email address using Levenshtein Distance.

Screenshot

How to use

Include MooTools, Mailcheck.js and String.levenshtein.js into the page:

<script type="text/javascript" src="mootools.js"></script>
<script type="text/javascript" src="https://github.com/thinkphp/String.levenshtein/blob/master/Source/String.levenshtein.js"></script>
<script src="mailcheck.js" type="text/javascript"></script>

When your user types in "adrian@yahuu.com", Mailcheck will suggest "adrian@yahoo.com".

    #HTML
   <p><label for="email">Email</label><input type="text" name="email" id="email" value="adrian@yahuu.com"/></p>
   <div id="suggestions"></div>

When DOM is ready:

    #JS

    var domains = ['hotmail.com', 'gmail.com', 'yahoo.com','aol.com','excite.com','thinkphp.ro']

    $('email').addEvent('keyup',function(){

       new Mailcheck($('email'),{domains: domains, onSuggested: function(suggestions){

           $("suggestions").set('html', '<span class="didyoumean">Did you mean </span>' + suggestions.join(", ") + " ?");

       },onEmpty: function(){

                 //do stuff
       }
       })
   })

References: