Email Typo Check
Suggests corrections for mistyped email domains — a non-blocking "Did you mean [email protected]?" hint shown when someone types gmial.com, yahoo.con, hotmial.com, and similar. It never blocks submission; it only offers a click-to-apply correction.
It wraps the actively maintained zootools/email-spell-checker (MIT) library, bundled for the browser.
Why this and not server-side validation?
Server-side validators catch malformed addresses (bad syntax, impossible TLDs). They cannot catch gmial.com, because that is a perfectly valid domain shape — it's just not what the user meant. This module targets exactly that typo class, on the client, as a suggestion. The two layers are complementary; keep your hard rejection server-side and use this for the "did you mean" nudge.
Usage
Option A — attach to everything (no code)
Enable Automatically attach to all forms at admin/config/content/email-typo-check.
Option B — attach selectively from your module (recommended)
Leave auto-attach off and call the service on the forms you care about:
// In hook_form_alter(), on the form render array root.
\Drupal::service('email_typo_check.attacher')->attach($form);
// Optional per-attachment overrides:
\Drupal::service('email_typo_check.attacher')->attach($form, [
'selector' => 'input[type="email"], .my-custom-email input',
'extra_domains' => ['mycompany.com'],
]);
The service (\Drupal\email_typo_check\EmailTypoCheckAttacherInterface) attaches the library and per-page settings; the client-side behaviour does the rest.
Extending the domain list
Site builders: add domains/TLDs on the settings form. Developers: implement hook_email_typo_check_domains_alter() (see email_typo_check.api.php). Both extend the library's built-in popular lists; they never replace them.
Third-party library
js/email-spell-checker.min.js is a bundled build of @zootools/email-spell-checker (MIT). See js/README.txt to regenerate or switch to a Composer/Asset-Packagist-managed copy before publishing on drupal.org.