JRS: In article <is**********@hotpop.com>, seen in
news:comp.lang.javascript, Lasse Reichstein Nielsen <lr*@hotpop.com>
posted at Tue, 13 Jan 2004 21:31:24 :-
As a non-.com-user, I would recommend just
var re = /.+@.+\..+/;
It accepts anything with a @ and a . in that order and with something
around it. Most attempts at being more precise will usually rule out
some perfectly good e-mail address.
There is the question of purpose.
If the wish is to accept anything that includes what might be an E-mail
address, one may need just that. It does, however, accept itself, which
seems generous.
I doubt whether anyone would intentionally provide a "normal" address
with anything but letters (plural) in the final field, so such a test
for that field being alpha 2+ should be safe enough, and would catch a
few gross blunders.
It is not the test used by my mailer Turnpike, though.
Turnpike will accept a mere
lr*@hotpop.com
and <lr*@hotpop.com>
but rightly also a full Lasse Reichstein Nielsen <lr*@hotpop.com>
It rightly rejects Lasse R. Nielsen <lr*@hotpop.com>
and accepts "Lasse R. Nielsen" <lr*@hotpop.com>
It rightly accepts also the possibly-deprecated form
lr*@hotpop.com (Denmark)
It rejects, in those, unmatched punctuation.
Where a form requires that an E-mail address be provided, the designer
should consider whether a fuller form should be allowed; and, if so,
that fuller form should be validated to Internet standards.
If collecting name & address * date of birth & e-mail address, the extra
may not be needed. But if the E-address given is to be used, then one
should IMHO be allowed to give it in a full form.
--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.