How to verify an email address

B

Bob Richardson

In a FrontPage web I'm trying to validate an email address to be sure it
meets some minimum format, perhaps something like ?@?.* I was told that
this could be done in javascript. Any help would be very much appreciated.
 
W

WindAndWaves

Bob Richardson said:
In a FrontPage web I'm trying to validate an email address to be sure it
meets some minimum format, perhaps something like ?@?.* I was told that
this could be done in javascript. Any help would be very much appreciated.

You can have a look at http://www.cem.co.nz/form/form.html, in the code you
can find a test for an email address.

Cheers

Nicolaas
 
H

Hywel Jenkins

"Bob Richardson" said:
In a FrontPage web I'm trying to validate an email address to be sure it
meets some minimum format, perhaps something like ?@?.* I was told that
this could be done in javascript. Any help would be very much appreciated.

A simple search at Google would have given you loads of options:
Try http://www.google.com/
Seasrch for javascript email validation
 
M

MyndPhlyp

Bob Richardson said:
In a FrontPage web I'm trying to validate an email address to be sure it
meets some minimum format, perhaps something like ?@?.* I was told that
this could be done in javascript. Any help would be very much appreciated.

Try this function. The RegExp might look a little strange, but if you take
the time to hash it out it at least covers all the permutations I could
think of at the time I wrote it. (Took a bit of work IIRC to wrap my mynd
around it when I did it a couple years ago.) You might need to embellish it
a bit to allow for the newer domain extensions.

function isValidEmail(parmValue) {
var rex = new
RegExp("^[\\w\\+-]+(\\.[\\w\\+-]+)?@((\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1
,3})\|([\\w\\+-]+\\.[a-zA-Z]{2,}))$");
var pos = parmValue.search(rex);
if (pos < 0) {
return false;
} else {
return true;
}
}
 
D

Dr John Stockton

JRS: In article <[email protected]>,
dated Sun, 21 Nov 2004 22:29:54, seen in
MyndPhlyp said:
Bob Richardson said:
In a FrontPage web I'm trying to validate an email address to be sure it
meets some minimum format, perhaps something like ?@?.* I was told that
this could be done in javascript. Any help would be very much appreciated.

Try this function. The RegExp might look a little strange, but if you take
the time to hash it out it at least covers all the permutations I could
think of at the time I wrote it. (Took a bit of work IIRC to wrap my mynd
around it when I did it a couple years ago.) You might need to embellish it
a bit to allow for the newer domain extensions.

function isValidEmail(parmValue) {
var rex = new
RegExp("^[\\w\\+-]+(\\.[\\w\\+-]+)?@((\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1
,3})\|([\\w\\+-]+\\.[a-zA-Z]{2,}))$");
var pos = parmValue.search(rex);
if (pos < 0) {
return false;
} else {
return true;
}
}

The occurrence in code of such as
if (pos < 0) { return false; } else { return true; }
inevitably casts doubts upon the sagacity and understanding of the
author, since
return pos >= 0;
suffices for the same purpose.


When posting code to News, the posting agent should NOT be allowed to
break code lines; it is the author's duty to avoid this.

The code accepts (e-mail address removed), but rejects (e-mail address removed); AFAIK, both are
valid.

The code rejects my own address; I assume that its author has not
studied the relevant Internet standards, and has little knowledge of the
world outside his own unspecified country.



OP : consider <URL:http://www.merlyn.demon.co.uk/js-valid.htm#VEmA>; you
must mean *@*.* not ?@?.* .
 
M

MyndPhlyp

Dr John Stockton said:
The occurrence in code of such as
if (pos < 0) { return false; } else { return true; }
inevitably casts doubts upon the sagacity and understanding of the
author, since
return pos >= 0;
suffices for the same purpose.

Po-ta-to versus po-tah-to. To-ma-to versus to-mah-to. Every programmer has
their own style, and even that evolves over time. :)

When posting code to News, the posting agent should NOT be allowed to
break code lines; it is the author's duty to avoid this.

The 'Net Police have yet to hand out fines. :) Although I haven't been
monitoring all the NGs, is it safe to assume you point that out to everybody
that posts line breaks even for URLs?

The code accepts (e-mail address removed), but rejects (e-mail address removed); AFAIK, both are
valid.

AFAIK, "name.name.name.name.ad-nauseam" is also a valid prefix and domains
with 4 (and more) parts are also to be expected. I would expect the
standards to become even more flexible over time. The author admitted the
RegExp may need tweaking to allow for today's permutations.

The code rejects my own address; I assume that its author has not
studied the relevant Internet standards, and has little knowledge of the
world outside his own unspecified country.

No facts in evidence regarding the author's knowledge of relevant Internet
standards or of the world outside his own unspecified country. Careful or
the 'Net Police will get you for unsubstantiated character assassination.
:)


Truth be known, the code was written as a personal challenge to come up with
a single RegExp for validating email addresses. At the time it was written,
the so-called standards were just breaking out of the 8-character limitation
on machine and account names. It hasn't been revisited in a very long time.
The tweaks necessary are relatively minor once the reader understands the
RegExp.
 
D

Dr John Stockton

JRS: In article <[email protected]>,
dated Mon, 22 Nov 2004 20:14:18, seen in
MyndPhlyp said:
Truth be known, the code was written as a personal challenge to come up with
a single RegExp for validating email addresses. At the time it was written,
the so-called standards were just breaking out of the 8-character limitation
on machine and account names. It hasn't been revisited in a very long time.
The tweaks necessary are relatively minor once the reader understands the
RegExp.

Right. So it was ancient trash not worth posting, since the OP can get
better advice from others. The address of mine which it fails to accept
has been in use for just over 9 years. The address I used earlier would
also not have been accepted, for the same reason.


Hywel - the trouble with your recommendation is that it is too likely to
find rubbish, which the OP may not recognise as such.


<FAQENTRY>ISTM that it would be good to have an entry on RegExps for
validation. Is the FAQ still being updated?
 
M

MyndPhlyp

Dr John Stockton said:
JRS: In article <[email protected]>,
dated Mon, 22 Nov 2004 20:14:18, seen in

Right. So it was ancient trash not worth posting, since the OP can get
better advice from others. The address of mine which it fails to accept
has been in use for just over 9 years. The address I used earlier would
also not have been accepted, for the same reason.


Hywel - the trouble with your recommendation is that it is too likely to
find rubbish, which the OP may not recognise as such.

At least I ventured, which is more than can be said for your "solution."
 
M

MyndPhlyp

Dr John Stockton said:
Presumably, therefore, you ignored the part aimed at the OP :-

Mere waving of the hands and banging of the gums void of a working solution
and lacking any substance greater than moist air passing over your lips
giving even more credence to the old adage: Those who can, do. Those who
can't, teach.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top