Email validation on sign-up forms without rejecting real people
Short answer: No pattern can tell you whether an email address really exists, and strict patterns reject real customers' addresses. Use the browser's built-in type="email" check, trim spaces, enforce the standard length limits, offer a gentle "did you mean…?" for obvious domain typos, and treat a confirmation link or a successful first email as the real test. Don't block plus signs, long domains, new top-level domains or apostrophes.
Why over-strict validation costs you customers
Developers often copy a regular expression from somewhere and add it to every form. The trouble is that real addresses are more varied than most patterns allow. Common false rejections include:
- Plus addressing, like
sam+orders@example.ca, which many people use to filter mail. - Apostrophes and hyphens in the local part, such as
o'brien@example.ca. - Newer or longer top-level domains, like
.consultingor.photography. - Subdomains, such as
name@mail.company.example. - Uppercase letters typed by phone keyboards.
Each rejection is a customer who couldn't sign up, book or check out, often without telling you why they left. Overly loose validation is a lesser problem: it lets a mistyped address through, which you can catch in other ways.
Use the browser's built-in check
The simplest good option is <input type="email">. MDN's documentation explains that the browser automatically validates that the value is either empty or a properly formatted address, strips leading and trailing whitespace, and on phones brings up a keyboard with the @ key handy. The multiple attribute allows a comma-separated list when you need one.
The HTML standard defines what "valid email address" means for this check, and it does so deliberately differently from the full email syntax standard. The specification describes its rule as a willful violation of RFC 5322, because that standard's syntax is at once too strict, too vague and too obscure for what web forms need. In other words, the browser check is designed to be practical.
Add autocomplete="email" so browsers can fill it correctly, and required if the field is mandatory.
Mirror it on the server
Browser checks can be bypassed, so validate on the server too. Keep the server rule close to the browser's so the two don't disagree:
- Exactly one
@, with something on each side. - No spaces after trimming.
- A domain with at least one dot, or match the browser's rule exactly.
- Length within the limits of the email standard.
RFC 5321, the SMTP standard, sets the maximum length of a local part at 64 octets, a domain at 255 octets and a full path at 256 octets including punctuation. Enforcing those prevents absurd inputs without rejecting real ones.
Most web frameworks include an email validator. Check how strict yours is, and loosen it if it rejects addresses like the examples above.
Catch typos kindly
The most common real problem isn't invalid syntax; it's a valid-looking typo like gmial.com, hotmal.com or .con. A typo suggestion helps without blocking:
Did you mean name@gmail.com?
Offer it as a one-tap fix next to the field, never as a block. Libraries exist for this, or you can maintain a short list of common domains and misspellings relevant to your customers.
Optional: check the domain can receive mail
A step further is to check that the domain has mail servers, by looking up its DNS records on the server. That catches typos like example.con and invented domains. Do it carefully:
- Only as a warning, or with a fallback, because DNS lookups can fail temporarily.
- With a short timeout, so the form doesn't hang.
- Without trying to connect to the mail server to "test" the mailbox, which is unreliable and can look like spam behaviour.
The real test: send something
Syntax and DNS checks can't confirm that the address belongs to the person. Only email can. Depending on what the address is for:
- Accounts: send a confirmation link and limit what unconfirmed accounts can do.
- Orders and bookings: send the confirmation straight away, and show the address on the thank-you page so customers can spot a mistake and fix it.
- Newsletters: use double opt-in, which confirms both the address and consent.
If someone does mistype their address on an order, make it easy to fix: let them update it from the order confirmation page or by replying to a text message, rather than starting again.
Watch your bounce handling too. Addresses that hard-bounce should be flagged in your app, so staff know to ask for a correct one.
Good error messages
When validation does fail, say what's wrong in plain words and keep what the customer typed:
- "Please include an @ in your email address" is better than "Invalid input".
- Show the message next to the field, not only at the top of the form.
- Never clear the field; let them correct the typo.
A worked example
Imagine a hypothetical Calgary home-renovation firm's quote form that used a pattern allowing only two-to-four letter domain endings and no plus signs. Several prospects with company domains on longer endings couldn't submit, and the firm only noticed when one phoned. The team switched to type="email" with a matching server check, added length limits, a typo suggestion for common domains and a thank-you page showing the address entered. Quote requests stopped failing on valid addresses, and typo corrections caught several mistakes before submission.
FAQ
Should I ask customers to type their email twice?
It adds friction and people often copy-paste the first one. Showing the address back and sending a confirmation works better.
Can I block disposable email addresses?
You can, using lists of disposable domains, but lists go out of date and may block legitimate users. Consider whether it's worth it for your form.
Are international email addresses valid?
Addresses with non-Latin characters exist and are growing. Support varies across systems, so test if your customers use them.
Is a regular expression ever the right tool?
A simple one, matching the browser's rule, is fine. Complex patterns aiming for full standards compliance usually cause more harm than good.
If your sign-up or enquiry forms might be turning away real customers, let us review your validation.