Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script src="https://cdn.jsdelivr.net/npm/[email protected]/src/mailcheck.min.js"></script>
- <script>
- (function () {
- const DOMAINS = [
- 'gmail.com','yahoo.com','hotmail.com','outlook.com','aol.com',
- 'icloud.com','me.com','live.com','msn.com','comcast.net',
- 'verizon.net','att.net','sbcglobal.net','bellsouth.net','cox.net',
- 'ymail.com','protonmail.com','mac.com'
- ];
- const TLDS = ['com','net','org','co','io','us','edu','gov','uk','ca','au','de','fr'];
- const EMAIL_RE = /^[^\s@]+@[^\s@]+\.[a-z]{2,}$/i;
- function setInvalid(input) {
- input.style.borderColor = '#dc2626';
- input.style.boxShadow = '0 0 0 3px rgba(220,38,38,0.25)';
- }
- function setValid(input) {
- input.style.borderColor = '';
- input.style.boxShadow = '';
- }
- function check(input, hint) {
- const v = input.value.trim();
- if (!v) { setValid(input); hint.style.display = 'none'; return; }
- if (!EMAIL_RE.test(v)) {
- setInvalid(input);
- hint.textContent = 'Please enter a valid email address';
- hint.style.display = 'block';
- hint.onclick = null;
- return;
- }
- Mailcheck.run({
- email: v,
- domains: DOMAINS,
- topLevelDomains: TLDS,
- suggested: function (s) {
- setInvalid(input);
- hint.innerHTML = 'Did you mean <strong style="text-decoration:underline;">' +
- s.full + '</strong>? (click to fix)';
- hint.style.display = 'block';
- hint.onclick = function () {
- input.value = s.full;
- input.dispatchEvent(new Event('input', { bubbles: true }));
- input.dispatchEvent(new Event('change', { bubbles: true }));
- setValid(input);
- hint.style.display = 'none';
- };
- },
- empty: function () {
- setValid(input);
- hint.style.display = 'none';
- }
- });
- }
- function attach() {
- document
- .querySelectorAll('input[type="email"], input[type="text"][name*="email" i], input[name*="email" i]')
- .forEach(function (input) {
- if (input.dataset.vAttached) return;
- input.dataset.vAttached = '1';
- const hint = document.createElement('div');
- hint.style.cssText =
- 'font-size:13px;line-height:1.3;color:#b54708;margin:4px 0 0;' +
- 'display:none;cursor:pointer;user-select:none;';
- input.parentNode.insertBefore(hint, input.nextSibling);
- input.addEventListener('blur', function () { check(input, hint); });
- input.addEventListener('input', function () {
- if (input.style.boxShadow) check(input, hint);
- });
- });
- }
- if (document.readyState === 'loading') {
- document.addEventListener('DOMContentLoaded', attach);
- } else {
- attach();
- }
- new MutationObserver(attach).observe(document.body, { childList: true, subtree: true });
- })();
- </script>
Advertisement
Add Comment
Please, Sign In to add comment