mailcheck
Version:
A standalone module that suggests a right domain when your users misspell it in an email address.
39 lines (34 loc) • 1.08 kB
HTML
<html>
<head>
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="../src/mailcheck.js"></script>
<title>Mailcheck</title>
</head>
<body>
<h1>Mailcheck</h1>
<p>For a demo, enter a@hotmale.com or b@gmail.co in the field below:</p>
<input id="email" name="email" type="email" />
<input name="Submit" type="submit" />
<p id="suggestion"></p>
<script>
var domains = ['hotmail.com', 'gmail.com', 'aol.com'];
var topLevelDomains = ["com", "net", "org"];
$('#email').on('blur', function(event) {
console.log("event ", event);
console.log("this ", $(this));
$(this).mailcheck({
domains: domains, // optional
topLevelDomains: topLevelDomains, // optional
suggested: function(element, suggestion) {
// callback code
console.log("suggestion ", suggestion.full);
$('#suggestion').html("Did you mean <b><i>" + suggestion.full + "</b></i>?");
},
empty: function(element) {
// callback code
$('#suggestion').html('No Suggestions :(');
}
});
});
</script>
</body>