|
We are declaring i to equal the length of the second element of the names array minus the numeric position of the first
occurrence of a period, starting from the right end of the string. If variable i does not equal "2" or "3", then the
email address is invalid. What this little snippet does here is checking for is to see how long the user specified their
TLD (Top-Level Domain [i.e. -- .com,.net,.org,etc.]) to be. And since top level domains do not exist that have more
than three characters, the period cannot be more than three characters from the left and the entered email address
be valid. If it is determined to be an invalid email address, the function is exited.
if InStr(email, "..") > 0 then
isitvalid=false
end if
if InStr(email, "..") > 0 then
isitvalid=false
end if
If anywhere in the passed string is the substring "..", the email address is invalid because a valid email address
cannot have two periods right together. No "exit function" statement is necessary here because the function is
finally over.
Summary :
I hope that I've taught you a few things over the course of this tutorial. Additionally, you may be wondering
how to execute the function. Its really very simple: just use the following line of code:
IsValidEmail("charles@dimsdale.com")
Of course, you can replace "charles@dimsdale.com" with your own email address, or more effectively the name of a
variable that holds a user entered email address.
If you have any questions, feel free to write me at charles@dimsdale.com or post a question in the FORUM. I'd be
glad to help. We are declaring i to equal the length of the second element of the names array minus the numeric position of the first
occurrence of a period, starting from the right end of the string. If variable i does not equal "2" or "3", then the
email address is invalid. What this little snippet does here is checking for is to see how long the user specified their
TLD (Top-Level Domain [i.e. -- .com,.net,.org,etc.]) to be. And since top level domains do not exist that have more
than three characters, the period cannot be more than three characters from the left and the entered email address
be valid. If it is determined to be an invalid email address, the function is exited.
if InStr(email, "..") > 0 then
isitvalid=false
end if
if InStr(email, "..") > 0 then
isitvalid=false
end if
If anywhere in the passed string is the substring "..", the email address is invalid because a valid email address
cannot have two periods right together. No "exit function" statement is necessary here because the function is
finally over.
Summary :
I hope that I've taught you a few things over the course of this tutorial. Additionally, you may be wondering
how to execute the function. Its really very simple: just use the following line of code:
IsValidEmail("charles@dimsdale.com")
Of course, you can replace "charles@dimsdale.com" with your own email address, or more effectively the name of a
variable that holds a user entered email address.
If you have any questions, feel free to write me at charles@dimsdale.com or post a question in the FORUM. I'd be
glad to help.
|