11 Replies Latest reply on May 11, 2015 5:17 PM by R12GS

# Using validation on an email address

### Title

Using validation on an email address

### Post

My students have to use validation on an email address for a particular task set by the exam board.

Can anyone tell me the validation rule that would enable them to this using FileMaker Pro 11 please.

Validation by calculation comes to mind???

• ###### 1. Re: Using validation on an email address

Perhaps:

Let ([ L = Length ( self ) ;
At = Position ( self ; "@" ; 1 ; 1 ) ;
Period = Position ( self ; L ; -1 ) ] ;
At > 1 and At < ( Period - 2 )
)

• ###### 2. Re: Using validation on an email address

Phil did you mean:

```Let ([ L = Length ( Self ) ;                             // get length of eMail address
At = Position ( Self ; "@" ; 1 ; 1 ) ;// Find at least one @ signred
Period = Position ( Self ;"." ;L ; -1 ) ] ;  // Find at least one period from a right to left search....RED arguement was missing.
At > 1 and At < ( Period - 2 )                // Return boolean T/F if @ and period were found in a normal email range
)```
` `
`Jim....`
• ###### 3. Re: Using validation on an email address

Yep. Thanks for the correction. Typed that one up before I had my morning caffiene hit...

• ###### 4. Re: Using validation on an email address

AFter further thought, this might be even better as the boolean expression at the end:

At > 1 and At < ( Period - 2 ) and Period < (L - 1)

This insists that Period be a position at least 3 places to the left of the end of the text string. (I don't think there are any valid email addresses such as this: name@Domain.a are there?)

• ###### 5. Re: Using validation on an email address

A few years ago I bought a book of Custom Functions that did a detailed check for the "top level domains" or the .com, .org, .gov  etc.  They claimed the list was easily updated.  Here is a partial list... gag...

ac ad ae aero af ag ai al am an ao aq ar arpa as at au aw az ba bb bd be bf bg bh bi biz bj bm bn bo br bs bt bv bw by bz ca cat cc cd cf cg ch ci ck cl cm cn co com coop cr cu cv cx cy cz de dj dk dm do dz ec edu ee eg er es et eu fi fj fk fm fo fr ga gb gd ge gf gg gh gi gl gm gn gov

the CF check this and what you easily programed.  The CF are copible if you wish me to emai them to you.

That list was 2 characters minimum as shown above.

However I have seen  Name.Last@Domain.xx

Brucey, I can eMail you the Custom functions also if you wish.

Jim...

• ###### 6. Re: Using validation on an email address

The validation I wrote should return true for Name.Last@Domain.xx , but not Name.Last@Domain.x

• ###### 7. Re: Using validation on an email address

PS, If I were to include a check on valid domains, I wouldn't use a custom function of such design, I'd use a related table of domains as it would be much simpler to update than a string enclosed in a CF.

• ###### 8. Re: Using validation on an email address

A good article on this:

basically there is no perfect way to validate an email address other than emailing it.

• ###### 9. Re: Using validation on an email address

And emailing it to see if it goes through or generates a "postmaster" error email back only confirms that the email address exists, it could still be the wrong email address for the data it is associated with.

This is typical of many data validation challenges. You can catch the obvious "format" errors, but cannot trap for every conceivable error as some errors will have the correct format, spelling, be a member of a value list, etc, but still be the wrong value.

• ###### 10. Re: Using validation on an email address

Yes, wouldn't use an email back as a validation. Have one solution where I send the user an email with a link (with a unique code) that they must click on which hits web page (php) that updates FileMaker to let it know it is valid. (Could even go further and have a captcha or something similar on that page to prove they are human).

• ###### 11. Re: Using validation on an email address

I've incorporated the Rhodes/Ramsey custom function to at least "hint" if an email may have a format error.  It's here: https://www.briandunning.com/filemaker-custom-functions/detail.php?fn_id=972#comment_bottom

======================

IsEmpty ( text ) or // Comment out this line if you want to prohibit null values.
Let ( [
_email = text;
_alphanum = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" ;
_email = Trim ( _email ) ;
_posAt = Position ( _email ; "@" ; 1 ; 1 )
] ;
Filter ( _email ; _alphanum & "_-@.!#\$%&'*+-/=?^_`{|}~" ) = _email // There are no invalid characters.
and PatternCount ( _email ; "@" ) = 1 // There is only one @ symbol.
and IsEmpty ( Filter ( Left ( _email ; 1 ) ; "@" ) ) // First and last character are alphanumeric.
and IsEmpty ( Filter ( Left ( _email ; 1 ) & Middle ( _email ; _posAt - 1 ; 3 ) & Right ( _email ; 1 ) ; "." ) )
and not Position ( _email ; ".." ; 1 ; 1 )
and Position ( _email ; "." ; _posAt + 2 ; 1 )
)

====================

Does anybody know how to modify this function to include validation to a small common list of suffixes?  We often see customer entered emails such as xxxx@gmail.cm (where you KNOW it should be gmail.com).  Apparently .cm is a valid suffix, but the vast number of suffixes we see are recognizable (.com, .org, .gov, .net)  I would like my script to validate to a short list of normal suffixes and notify the operator if the suffix is not in the normal list.  I suppose a short 'list' could be hard coded in the custom function?  Also if anybody has a recommendation of the "common suffixes" that's interesting too.

I can understand this custom function "a little" but couldn't edit it myself, so would need pretty basic help.  I probably could figure out how to add or remove a suffix though, once that feature was added.

TIA!