WD,
One way is to create several calculated fields, each comprising one of the
criteria.
So, you have the following fields:
Email (text)
endsEmail (calc txt) = Left(Email,1) & Right(Email,1)
posDomain (calc, num) = Position (Email,"@",1,1)
Domain (calc, txt) = Case (posDomain, Right (Email,
Length(Email)-posDomain))
leftDomain (calc, txt) = Left (Domain,1)
posTLD (calc, num) = Case (posDomain, Position(Domain,".",1,1))
TLD (calc, txt) = Case (posTLD, Right(Domain, Length(Domain)-posLTD))
posDot (calc, num) = Position(Email,".",1,1)
countanEmail (calc, num) = PatternCount(Email,"a") +
PatternCount(Email,"b") ++ PatternCount(Email,"9") ++
- - (only need lower case letters, numbers and extra permitted
characters)
countaEndsEmail (Calc, txt) = PatternCount(endsEmail,"a")
+++ PatternCount(endsEmail,"z")
- - (only need lower case letters)
countaLeftDomain (calc, num) = PatternCount(leftDomain,"a")
+++ PatternCount(leftDomain,"z")
- - (only need lower case letters)
countAtEmail (calc, num) = PatternCount(Email,"@")
Then combining these results
ValidEmail (calc, txt) = Case(
not IsEmpty(Email) and
countanEmail = Length(Email) and
countAtEmail = 1 and
countaEndsEmail = 2 and
countanLeftDomain = 1 and
PatternCount(Email, "..") = 0 and
Middle(Email,posDomain-1,1) ≠ "." and
not IsEmpty(TLD),
"Valid", "Invalid")
If you're feeling really confident, all of these calculations can be
combined into one final Validation calculation. It might be a little
difficult to check for bugs though.
Ross
On Mon, Dec 6, 2010 at 1:36 AM, W. D. <[email protected]> wrote:
> Michael Rhodes has a good one for modern versions:
>
> /*
> Created October 12, 2008
> Updated December 5, 2010
>
> Since new top-level domains are constantly added, this function assumes the
> top-level domain is legitimate and validates only the email format.
> Returns a True value if the parameter is a correctly formatted email
> address.
>
> Created by Michael Rhodes
> [email protected]
> Anybody may use this function so long as they keep my contact info in the
> comments of the function.
> */
>
> IsEmpty ( text )
> or
> Let ( [
> alphanum =
> "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" ;
> textEnds = Left ( text; 1 ) & Right ( text; 1 ) ;
> posDomain = Position ( text; "@"; 1; 1 ) ;
> domain = If ( posDomain; Right ( text; Length ( text ) - posDomain ) ) ;
> leftChar = Left ( domain; 1 ) ;
> posTLD = If ( posDomain; Position ( domain; "."; 1; 1 ) ) ;
> TLD = If ( posTLD; Right ( domain; Length ( domain ) - posTLD ) )
> ] ;
> Filter ( text; alphanum & "_...@.'/+" ) = text // There are no invalid
> characters.
> and PatternCount ( text; "@" ) = 1 // There is only one @ symbol.
> and Filter ( textEnds; alphanum) = textEnds // First and last character
> are alphanumeric.
> and not Position ( text; ".."; 1; 1 )
> and Middle ( text; posDomain - 1; 1 ) <> "."
> and Filter ( leftChar; alphanum ) = leftChar
> and not IsEmpty ( TLD )
> ) // end let
>
> Anyone have any suggestions for version 6?
>
>
> Start Here to Find It Fast!™ ->
> http://www.US-Webmasters.com/best-start-page/
> $8.77 Domain Names -> http://domains.us-webmasters.com/
>