HTML and CSS Reference
In-Depth Information
17.5.7 Checking for Valid E-Mail Addresses
When validating an e-mail address, you are looking for the typical format found in such
addresses. There might be some domain names that are more than three characters, but
it isn't typical. Also, just because the user types what looks like a valid e-mail address,
that does not mean that it is; for example, the e-mail address santa@northpole.org uses a
valid syntax, but that fact does not prove that santa is a real user.
E-mail addresses usually have the following format:
An @ sign between the username and address ( lequig@aol.com ).
At least one dot between the address and domain name ( .com , .mil , .edu , .se ).
At least six characters ( a@b.se ). 3
Examples of valid e-mail addresses:
username@mailserver.com
username@mailserver.info
username@mailserver.org.se
username.moretext@mailserver.mil
username@mailserver.co.uk
user-name.moretext.sometext@mailserver.se
To break down a simple e-mail regular expression
/^(([\-\w]+)\.?)+@(([\-\w]+)\.?)+\.[a-zA-Z]{2,4}$/;
use the following steps:
Step 1:
^
Go to the beginning of the line.
Step 2:
([\-\w]+)\.?
The username consists of one or more dashes or word
characters grouped by parentheses, followed by one
(or not one) literal period. Because the dot is outside
the parentheses, there will be either one or zero dots
for the list of word characters, not two or three dots in
a row.
Step 3:
(([\-\w]+)\.?)+
The username can consist of more than one set of
word characters separated by a single dots, as in
Joe.Shmoe.somebody.
Step 4:
@
A literal @ symbol is required in the e-mail address.
Step 5:
([\-\w]+)\.?)+
The mail server's name is like the user's name, a group
of word characters separated by a dot.
3. As of this writing, domain names have at least two characters.
 
 
Search WWH ::




Custom Search