R
E
S
O
U
R
C
E
S
       Home      Products & Services      Contact Us      Links


WebHatchers will design & develop your site for you.
_______________________

Website Menu Heaven: menus, buttons, etc.
_______________________

Send us your questions.
_______________________

site search by freefind
_______________________

HOME
SEO, Google, Privacy
   and Anonymity
Browser Insanity
JavaScript
Popups and Tooltips
Free Website Search
HTML Form Creator
Animation
Buttons and Menus
Counters
Captchas
Image Uploading
CSS and HTML
PHP
AJAX
XPATH
Website Poll
IM and Texting
Databases—MySQL
   or Not MySQL
Personal Status Boards
Content Management
   Systems
Article Content
   Management Systems
Website Directory
   CMS Systems
Photo Gallery CMS
Forum CMS
Blog CMS
Customer Records
   Management CMS
Address Book CMS
Private Messaging CMS
Chat Room CMS
JavaScript Charts
   and Graphs




Free Personal Status Boards (PSB™)

Free Standard Free PSB

Free PSB Pro Version

Free Social PSB

Free Social PSB Plus (with Email)

Free Business PSB

Free Business PSB Plus (with Email)

PSB demo

Social PSB demo

Business PSB demo

So what's all this PSB stuff about?

Chart comparing business status boards

PSB hosting diagram

PSB Licence Agreement



Copyright © 2002 -
MCS Investments, Inc. sitemap

PSBs, social networking, social evolution, microcommunities, personal status boards
PSBs, social networking, business personal status boards
website design, ecommerce solutions
website menus, buttons, image rotators
Ez-Architect, home design software
the magic carpet and the cement wall, children's adventure book
the squirrel valley railroad, model railroad videos, model train dvds
the deep rock railroad, model railroad videos, model train dvds

Regular Expression Email Validator

The source code for the Regular Expression Email Validator is at the bottom of the page. A discussion of what we did precedes the code. Just before that you'll find a link giving you the opportunity to try out the Regular Expression Email Validator. If you use it somewhere on the Net, please give us a dofollow backlink with link text: "Regular Expression Email Validator". Thank you. Below, you'll see a grueling series of test Emails we subjected our Regular Expression Email Validator to, followed by the results. First we will look at Emails that validated, and our comments about the results. Then we will look at Emails that did not validate, and our comments about why these were the correct results. It is probably obvious that with new top domains appearing all the time, we couldn't be expected to use (com|info|biz| etc. . . ) as a hugely long, ever-expanding parenthesis-enclosed set of literals separated by the alternation operator |. Country codes change as well, so we check only for the required 2 letter character match. So one can get plenty of nonexistant Emails validated, but the same is true of URL validators, etc. We check the format, making sure their input seems legitimate. Similarly, no HTML/JavaScript page can actually try out the emails or the URLs to make sure they exist. That would not be doable or practical. Please send us comments about how you like our validator.

Be forewarned that we used many bogus names for things just to keep you on your toes, so mysite, for example, may represent site name or subdomain, according to their format inspection and .com may be many things besides top domain.

THESE EMAILS WILL VALIDATE:
JOEjoe@mysite.com uppercase is fine
JOE.joe.joe.joe@mysite.com usernames with dot-separated words are fine too
www.joe.joe.joe@mysite.com this is okay but the www will NOT be interpreted as the server world wide web
JOEjoe@mysite.com.co final co is country code
JOEjoe@mysite.com.com mysite is seen as subdomain and 1st .com is seen as site name and 2nd .com is seen as top domain
JOEjoe@mysite.com.com.co mysite is seen as subdomain and 1st .com is seen as site name and 2nd .com is seen as top domain and final co is country code
JOEjoe@mysitecom.com.com.co mysitecom is seen as subdomain and 2nd com is seen as site name and 3rd com is seen as top domain and final co is country code
JOE_k.jk-joe@mysite.com - and _ characters are allowed in username section
JOE_k.jk-joe@my-site_.com - and _ characters are allowed in domain section
JOE_k.jk-joe@my-SITE_.com uppercase is fine in domain section
JOE_k.jk-joe@my-SITE_.museum.museum.uk my-SITE_ is seen as subdomain and 1st museum is seen as site name and 2nd museum is a real top domain name, and uk is a real country code



THESE EMAILS WILL NOT VALIDATE BECAUSE:
JOE_k.jk-joemy-SITE_.museum.museum.uk missing @
JOE@joe@mysite.com.com.co 1 too many @s
JOE..joe@mysite.com.com.co 2 dots in a row is incorrect
JOE.joe.@mysite.com.com.co dot before @ is incorrect
.JOE.joe@mysite.com.com.co dot as 1st character is incorrect
JOE.joe@.mysite.com.com.co dot after @ is incorrect
JOE.joe@mysite.com.com.com final com is country code which needs to be 2 characters
JOE.joe@mysite.com.commune.co commune is top domain which must be 2-6 characters, not 7
JOE*joe@mysite.com.com.co only letters, numbers, hyphens, underscores and dots are allowed
JOE.joe@mysite..com.co 2 dots in a row is incorrect
JOE.joe@mysite.mysite.mysite.com.co mysite is okay as subdomain, site name, and top domain (the latter must be 2-6 characters), but then .com before .co needs deleting
JOE.joe@mysite.com.co. dot as last character is incorrect
JOE.joe@mysite!.com.co no ! allowed in url; only letters, numbers, hyphens, underscores and dots are allowed



Just because "mysite" looks like a site name, below, doesn't change the fact that the following validate because the formatting shows that com.com, museum.com, and museum.museum are the domains below, and mysite is in the subdomain position, as formatted. d@subdomain.domain.com.co gives a truer picture, and is formatted similarly to the other URLs. The domain is domain.com, not just domain, with .com as the top domain part.

d@mysite.com.com
d@mysite.com.com.co
d@mysite.museum.com.co
d@mysite.museum.museum
d@mysite.museum.museum.co

d@subdomain.domain.com.co

In the above address, d is the username, subdomain is the subdomain, domain.com is the domain with .com being the top level domain, and co is the country code.

[username][subdomain, like in http://images.google.com][domain, ends with top-level domain like .com][2-digit country code]

There's no way to know that com or biz or info or museum are top level domains instead of site names except by their position in the email formatting. Positioning is what our validation script uses to figure out which they are.

The code below lets you test various emails to check what will or will not validate with the check() function. Note that we did not allow IP addresses for the domain, however legal. In the code, for testing we used: {alert("Email address validated OK.");return false}} but when you actually use the code, change this alert code to simply {return true}}, and add an appropriate action in the form tag.

Now let's look at the regular expression we used:

The ^ says to match right after the start of the string (inputted URL). The [A-Za-z0-9-_]+ means it's necessary that the string being matched contains at least 1 legal character before the @, and it's not okay if it doesn't. The + means there must be one or more of what is enclosed in the character class.

The (\.[A-Za-z0-9-_]+)* section says it is okay to have more characters before the @, with at least one character between dots, and the optional indicated by a *, which means from 0 to many repetitions is okay. The dot is escaped with \ which means we want its literal meaning, not its operator meaning. (As an operator, a dot means "match any character.") Note that alphanumeric characters as well as - and _ are allowed in emails, so we allow them here, but if you're including another set of letters and/or numbers, you must begin it with a period. So the \. is obviously indicating just that. But the + is not as straightforward. The []s are a "character class", also called "character set", with which you can tell the regex engine to match only one out of several characters. So if you're including another set of letters and/or numbers, the bracketed area shows the choices, while the + says there must be 1 or more of these characters. Note this does NOT mean you have to have another set of letters and/or numbers in your input string. It means that IF YOU DO have another set of letters and/or numbers, it must contain 1 or more of the bracketed characters (and, of course, the period).

Next, after the @, comes ([A-Za-z0-9-_]+\.)?, the subdomain section whose character class is identical to the previous section, and they both end with a + sign, meaning it is not optional—you must have at least one of these characters followed by a dot if you use it, since we are now in the optional subdomain part of the domain. The next bunch of code is ([A-Za-z0-9-_]+, the required domain section, with a plus saying you must use one or more characters. The first parenthesis in this domain section has its mate just before the $ at the end of the regular expression. These grouping operators enclose areas by use of an open and close parenthesis and whatever immediately follows the group applies to the group. The dollar sign is the opposite of the ^ sign. The $ means to match right before the end of the string. It is important to have this set of parenthesis because the domain section, then the top domain section, then the optional country code, must all be adjascent and at the end. The next parenthesis set (\.[A-Za-z]{2,6}) forces a period and then a top domain of 2 to 6 letters. The {} brackets mean {min,max}, i.e., the least to the most letter characters that will match the input string's top domain. If they have 0, 1, or more than 6, the match will fail. (The top domains travel and museum both require 6 characters.)

The (\.[A-Za-z]{2})? is the optional country code—hence the question mark. Note it requires a period at the start IF it is used. And it must have 2 characters. Hence the {2}. Finally, we see the close parenthesis that, with its open parenthesis mate, groups the subdomain, the domain, and the country code just before the $ which means to match these groups at the end of the string. The country code is optional—hence the ?. The ?, *, and + are repetition operators. The question mark means 0 or 1 repetitions are okay. The * means 0 or more repetitions are okay. The plus means 1 or more repetitions are okay. Since we used the ? we know that 0 repetitions of a set of 2 letter characters are okay but so is putting one group of them.



Try the Regular Expression Email Validator.

Good info site for learning about Regular Expressions.



<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252">
<TITLE>Regular Expression Email Validator</TITLE>
<meta name="description" content="Good, Tested, Regular Expression Email Validator">
<meta name="keywords" content="Regular Expression Email Validator,javascript, dhtml, DHTML">

<script language=javascript>

function check(){

var ck_email = /^[A-Za-z0-9-_]+(\.[A-Za-z0-9-_]+)*@([A-Za-z0-9-_]+\.)?([A-Za-z0-9-_]+(\.[A-Za-z]{2,6})(\.[A-Za-z]{2})?)$/;
if(document.form.email.value.search(ck_email)==-1)
{alert("That email address is not valid.");return false}else

{alert("Email address validated OK.");return false}}

</script>
</HEAD>
<body>
<BR><BR><BR><BR>
<form style='margin-left:140px' name='form' action=" " method="POST" onsubmit="return check()">
Avoid "display name" and < > characters. Use this form: <span style='color:blue'>john.smith@example.com</span>.<br>Country codes are okay. Uppercase letters are okay. Use letters, numbers, hyphens, underscores and dots.<br>
<INPUT maxLength="80" type="text" name="email" size="80">
<INPUT TYPE="SUBMIT" value="Submit Email">
<INPUT TYPE="RESET" value="reset">
</form>
</BODY>
</HTML>