EMail Address Validation using Regex (Regular Expression)
A regular expression is text string in a particular format that can be parsed by a
regular expression processor to extract information out of other text data, and to
determine if text data meets certain formatting parameters.
Webmasters can use regular expressions to validate html form data by adding a little
JavaScript to their form.
Determine Email Address Validity Using a 'Regular Expression'.
One popular use of regular expression JavaScript is to determine if a website visitor
has entered a real email address or not. Many different regular expressions are suited
to performing this task. This page presents the one that we use.
The RegEx code operates under the following assumptions.
-
The part of the email address before the "@" sign can consist of the letters A-Z, the
numbers 0-9, as well as the dash "-", underscore "_", and period "." symbols.
-
The portion of the domain name before the TLD
(top level domain like .com) or country code must consist of at least 3 characters within the list A-Z or numbers 0-9, periods, or dashes.
- The portion of the domain name before the TLD can not start or end in a period or dash.
- The TLD (top level domain) or country code is in the list at
http://www.iana.org/domains/root/db.
-
Additional foreign language characters other than A-Z, 0-9, period, dash and underscore are not supported.
Some non-English email addresses use additional characters.
Software License
You may copy and reuse this example code within your web pages or other programs provided
that you agree to the following terms.
- Spectrum Research, Inc. takes no responsibility as to its use or misuse by you.
- Spectrum Research, Inc. We make no warranties as to its quality, or anything else.
- You may not resell this regular expression.
-
Other than reusing the presented regular expression in your own code, you may
not duplicate this web page in whole or in part.
- Spectrum Research, Inc. will provide no technical support for this code.
-
You must link back to this page by using the code below from some page on your
website that uses this code, using the following code. The page must be able to
be seen by search engine robots, meaning that you have to link to the page that
this code is on from some other page within your navigation structure, and you
can't exclude the page that links to us by using robot exclusion meta tags or the
robots.txt file, or other techniques that prevent search engine robots from seeing
the page that links to us.
Source Code
To get the source code for the email validation regex function, read the license above and then click
I Agree if you agree to the terms of the source code license.
Press the "Save Source Code" button below to save the code to Notepad.
|