IsValidEmailFormatƒ ( _email )
Validate email address
Average rating: 3.7 (55 votes) Log in to vote
Michael Rhodes Allied Data Service http://allieddataservice.com |
Function definition: (Copy & paste into FileMaker's Edit Custom Function window)
Purpose
Since the number of top-level domains increases over time, this function assumes the top-level domain is legitimate and prohibits invalid email formats caused by other data entry error.
Returns 1 if the parameter is a correctly formatted email address.
Comments
Benka, Rennes, France Jun 3, 2009 |
||
Hello Michael Thanks for this very usefull function. Little bug : text@text_text.com return true text.@text.com return true text@text.c return true text@text.text return true here is a list of top level domain http://en.wikipedia.org/wiki/List_of_Internet_top-level_domains |
||
Michael, Rancho Cuamonga, CA Jul 13, 2009 |
||
Benka, I have revised the function to address the first two conditions and more. The remaining conditions are not supposed to be tested by this function. As the comments state, because top level domains can be added in the future, this function assumes the top level domain is legitimate. The alternative would require all distributed solutions using the function to be updated every time ICANN decides to add another TLD. However, if that's what you prefer, you can use IsValidEmail, which I have also posted just in case. |
||
Jack James, London, UK Jun 22, 2010 |
||
An apostrophe (’) is a valid email address character | ||
Andreas Thyholdt, dbConsult AS Oct 6, 2010 |
||
test@example. return true |
||
Andreas Thyholdt, dbConsult AS Oct 6, 2010 |
||
The above is fixed with this additional clause: and IsEmpty ( Filter ( Left ( text; 1 ) & Right ( text; 1 ); "." ) ) // . symbol is not first or last character. |
||
Kevin Smith, Europe Oct 9, 2010 |
||
Thanks for the great function. I've revised it to permit the following additional characters: +/' Wikipedia says: Conversely, many websites make the mistake of checking email addresses too strictly, rejecting addresses containing perfectly valid characters like + or / signs. |
||
Markus Hediger, Switzerland, Dietikon Dec 18, 2010 |
||
Es hat alles super funktioniert. Vielen Dank für diese Hilfe! | ||
Bee, Atlanta Jan 15, 2011 |
||
Great function! But it should start with: not IsEmpty ( text ) and Let ( [ to prevent entry of an empty address |
||
Michael Rhodes, Rancho Cucamonga Jan 15, 2011 |
||
Bee, Only if you do not want to allow Null values. However, usually you do. And if you don't the edit is pretty simple as you figured out. |
||
Jamie Thompson, Computech IT Services Ltd., Plymouth, UK Mar 10, 2011 |
||
Great function. However, the ampersand (&) is a valid character in an email address. http://www.BusinessManCRM.com |
||
Jonathan Fletcher, Fletcher Data Consulting Jan 2, 2013 |
||
According to wikipedia, these characters are also legal in an email address: !#$%&'*+-/=?^_`{|}~ There's even more at: http://en.wikipedia.org/wiki/E-mail_address#RFC_specification ::-) |
||
James David Ramsey, Columbus, OH Feb 7, 2013 |
||
The function as defined is not a valid calculation. The '_email' reference in line 1 isn't defined until inside the let() statement which follows it. Easiest Fix: IsEmpty ( _email ) or BECOMES IsEmpty ( text ) or |
||
James David Ramsey, Columbus, OH Feb 7, 2013 |
||
And actually, the '_email' definition in the let statement is circular, so '_email' is never actually defined. Either change the incoming parameter to '_email' (which would also fix my earlier comment), or add ' _email = text;' early in the let statement. My new version: /* Created October 12, 2008 Updated January 1, 2012 Since top-level domains are constantly added, this function assumes top-level domain is legitimate and validates only the email format. Returns True if parameter (_email) is correctly formatted. By Michael Rhodes mike@allieddataservice.com */ 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 ) ) |
||
Arjen van der Ree, Amsterdam Jun 11, 2014 |
||
I have to admit that I used James David Ramsey version of your function Michael. Besides that I have to thank you for posting this here, saved me a lot of time ! With regards to both (Micheal and James) Arjen van der Ree Maxperts Filemaker 13 Certified dude |
||
tom, ShiftPoint May 11, 2015 |
||
Can you check the suffix against a list? For example an email with .com error fred13@gmail.cm | ||
Jean-Luc Marechal, Dakar, Senegal Mar 17, 2017 |
||
Thank you so much ! Jean-Luc |
||
Michael Rhodes, Colorado Springs, USA Mar 17, 2017 |
||
_email is the name of the passed parameter. If you choose to name the parameter "text", then yes you will have to add _email = text in the let statement. | ||
Florence Haseltine, Alexandria VA Dec 15, 2017 |
||
Thank you Caught my mistakes |
||
Carson Lind, Eagle Optimizations, LLC Feb 12, 2018 |
||
A warning that this function does not look for bad characters in the domain portion. Example: test@a!!!a.com returns true My fix: /* Created by Michael Rhodes 2008-10-12 Updated 2017-03-17 mike@allieddataservice.com This function assumes top-level domain is legitimate and validates only the email format. Returns 1 if parameter (_email) is correctly formatted. */ IsEmpty ( _email ) or // Comment out this line if you want to prohibit null values. Let ( [ _alphanum = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" ; _email = Trim ( _email ) ; _posAt = Position ( _email ; "@" ; 1 ; 1 ); _localpart = Left ( _email ; _posAt - 1 ); _domain = Middle ( _email ; _posAt + 1 ; 99999 ) ] ; Filter ( _localpart ; _alphanum & "!#$%&'*+-/=?^_`{|}~" ) = _localpart // There are no invalid characters in local part. and Filter( _domain ; _alphanum & ".-" ) = _domain //There are no invalid characters in the domain. and PatternCount ( _email ; "@" ) = 1 // There is only one @ symbol. and Length ( Filter ( Left ( _email ; 1 ) & Middle ( _email ; _posAt - 1 ; 3 ) & Right ( _email ; 1 ) ; _alphaNum ) ) = 4 // First and last character are alphanumeric. and not PatternCount ( _email ; ".." ) and Position ( _email ; "." ; _posAt + 2 ; 1 ) ) |
||
Christopher Augustin, Palm Desert Feb 14, 2018 |
||
Does not work. Every time I get errors. I have it set up in a field validation with everything accurate. | ||
Carson Lind, Eagle Optimizations, LLC Feb 15, 2018 |
||
Missed the period in local part validation: /* Created by Michael Rhodes 2008-10-12 Updated 2017-03-17 mike@allieddataservice.com This function assumes top-level domain is legitimate and validates only the email format. Returns 1 if parameter (_email) is correctly formatted. */ IsEmpty ( _email ) or // Comment out this line if you want to prohibit null values. Let ( [ _alphanum = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" ; _email = Trim ( _email ) ; _posAt = Position ( _email ; "@" ; 1 ; 1 ); _localpart = Left ( _email ; _posAt - 1 ); _domain = Middle ( _email ; _posAt + 1 ; 99999 ) ] ; Filter ( _localpart ; _alphanum & ".!#$%&'*+-/=?^_`{|}~" ) = _localpart // There are no invalid characters in local part. and Filter( _domain ; _alphanum & ".-" ) = _domain //There are no invalid characters in the domain. and PatternCount ( _email ; "@" ) = 1 // There is only one @ symbol. and Length ( Filter ( Left ( _email ; 1 ) & Middle ( _email ; _posAt - 1 ; 3 ) & Right ( _email ; 1 ) ; _alphaNum ) ) = 4 // First and last character are alphanumeric. and not PatternCount ( _email ; ".." ) and Position ( _email ; "." ; _posAt + 2 ; 1 ) ) |
||
Mariusz Klecha Oct 4, 2018 |
||
Hi Great function, thanks for sharing with us ! Did you think about the update it so it will check the length of the end address of the domain? What I mean is, the function retursn 1 if the address is "name@domainname.c" , as it seems that there are no addresses with only one letter at the end "c". Should be at least two. |
||
Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.