- Feature Articles
- CodeSOD
- Error'd
-
Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Edit Admin
The user must do something? I don't think so. The user always has the option of leaving your website, turning the computer off, and going to the beach.
Edit Admin
Oh great, another one who wants to punish poor
john@uk
...Admin
Remy, the parenthetical comment contains a "they're"/"their" mistake.
Admin
"in all they're forms" -> their
Admin
I love the check that the address shouldn't end with a dot, since that kicks out the very valid [email protected]. variant.
Admin
It says they must do theze things "for a response." If they don't want a response then, yes, they are free to leave. I don't think the statements are inaccurate.
Edit Admin
Apparently the programmer heard that if you solve a problem with regex, you now have two problems, so they solved the problem with more problems.
Edit Admin
Wait, an email address can end with a dot? Is
[email protected].
just another way to write[email protected]
or is it a different address?Addendum 2025-03-03 09:58: Looks like Cloudflare is protecting those sample email addresses. The question is whether the domain
domain.tld.
is different fromdomain.tld
.Edit Admin
Well, duh. You should have used
[email protected].
and[email protected]
, as God and RFC 2606 intended.Edit Admin
I'm pretty sure they're equivalent. In DNS, ending a name with a dot makes it absolute instead of relative. But I don't think the hostname in mail is ever treated as relative, so a trailing dot is redundant.
Admin
Beginner:
email.contains('@');
Intermediate:
(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+
Advanced:
email.contains('@');
Edit Admin
If I just saw "@uk..." or "@example.tld." in an email field, I'd say that's invalid, and 99% of the time I'd be right.
These are not RFC 5322 compliant.
Admin
What does str.indexOf(at)==lstr do?
If the character is present, indexOf returns its position, which will be in the range 0 to length - 1.
lstr is the length of the string.
Therefore, str.indexOf(at)==lstr will always be false.
Similarly, str.indexOf(dot)==lstr will always be false.
Admin
Validation is like crack to some programmers. If it's 99.9999999%, still don't. Even a syntactically valid address may not actually exist. And what's the chance that any user will ever accidentally omit the TLD and be saved by your cleverness? A typo that leave steh address syntactically valid is infinitely more likely, so design your app to be able to easily recover from that state and the benefit of obsessive validation becomes even smaller. Make inner peace with the fact you can't truly validate email and stop trying. Those 5 users will feel enough relief for a million.
Admin
I love how every attempt at showing some weird email variant ends up in failure…
Admin
like an icing on a cake, this is the off-by-one error, hiding in plain sight.
Edit Admin
Similar to date processing or "legal name" processing. It's just a thorny problem with very few good worked solutions that nobody seems to discover without going through the pain of doing it the wrong way a few times.
Edit Admin
Well, there's one stunningly simple way to validate email addresses: send an email message to that address with a confirmation link and wait for the user to click the link.
... though I have seen some convincing arguments to put up an "are you sure" message up if the entered domain is close to one of the big email providers (eg., "@gamil.com") or if the local part is close to the name (eg, if I entered "[email protected]").