Last active
May 12, 2016 13:07
-
-
Save eojeel/5825b53e087049d5e28d46c1febd9f13 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <script type="text/javascript" language="Javascript" src="/wp-content/themes/writeadultfiction/js/mailcheck.min.js"></script> | |
| <script type="text/javascript"> | |
| jQuery(document).ready(function($){ | |
| var domains = ["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", "mail.com", "outlook.com"]; | |
| var topLevelDomains = ["co.uk", "com", "net", "org", "info", "edu", "gov", "mil"]; | |
| // var superStringDistance = function(string1, string2) { | |
| // string distance algorithm of your choosing | |
| // } | |
| $('#wlm_email_field').on('blur', function(){ | |
| $(this).mailcheck({ | |
| domains: domains, | |
| topLevelDomains: topLevelDomains, | |
| //distanceFunction: superStringDistance, | |
| suggested: function(element, suggestion) { | |
| var $parent = $('#wlm_email_field').parent(); | |
| $('.szbl-mailcheck-msg', $parent).remove(); | |
| $parent.append('<span class="szbl-mailcheck-msg">Did you mean <a id="link" class="szbl-mailcheck-suggestion">' + suggestion.full + '</a>?</span>'); | |
| }, | |
| empty: function(element) { | |
| var $parent = $('#wlm_email_field').parent(); | |
| $('.szbl-mailcheck-msg', $parent).remove(); | |
| if ( !$('#wlm_email_field').val().match(/^[a-zA-Z]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$/) ) | |
| $parent.append('<span class="szbl-mailcheck-msg szbl-mailcheck-error">Please enter a valid email address.</span>'); | |
| } | |
| }); | |
| $('#link').click(function(){ | |
| $('#wlm_email_field').val( $(this).html() ); | |
| $(this).parent().remove(); | |
| }); | |
| }); | |
| }); | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment