Discussion Locked

Email id validation

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hee

I have a visual basic form in which the user has to enter his email id.
How can i check if a valid email id is entered by him?

Can anyone please help me in this regard?

Thanks in advance
Indira.

5 replies

by jay eckles

To check the validity of an email address's syntax, check that the string contains only one @ character, that there are one or more characters before the @, and that only valid domain name syntax follows the @.

The part before the @, known as the local-part, can be anything (see RFC 2821, SMTP sec 2.3.10), but it must be at least one character.

The part after the @, known as the domain, must start with a letter or number and contain no other characters except dashes (-) and dots (.). The domain must end with a letter or number (specifically, if it's an internet domain, it must end with a minimum of two letters). Sorry I don't have the specific RFC number available. There are practical limits to the length of the domain part, but I don't think that there is a specified limit.

So to summarize, I would do the following to validate the syntax of an email address:

1. Check for the existence of one and only one @ character
2. Check for one or more characters before the @3. Check for a valid domain after the @, which starts with a letter or number, contains only letters, numbers, dashes (-), and dots (.), and ends with at least two letters preceded by a dot (if you're validating internet-only addresses. Local domains may not end in .xx(x) ).

Jay Eckles
www.jayeckles.com

This discussion is closed to new replies.