isEmail(str)
Last updated July 29, 2008
Version: 6 | Requires: ColdFusion 5 | Library: StrLib
Description:
Tests passed value to see if it is a valid e-mail address (supports subdomain nesting and new top-level domains).
Return Values:
Returns a boolean.
Example:
#YesNoFormat(IsEmail("jguillaume@stoneage.com"))#<br>
#YesNoFormat(IsEmail("jguillaume@stoneage.com.info"))#<br>
#YesNoFormat(IsEmail("jguillaume@subdomain.stoneage.museum"))#<br>
#YesNoFormat(IsEmail("jguillaume@stoneage.invalidTLD"))#
</cfoutput>
Parameters:
| Name | Description | Required |
|---|---|---|
| str | The string to check. | Yes |
Full UDF Source:
<cfscript>
/**
* Tests passed value to see if it is a valid e-mail address (supports subdomain nesting and new top-level domains).
* Update by David Kearns to support '
* SBrown@xacting.com pointing out regex still wasn't accepting ' correctly.
* More TLDs
* Version 4 by P Farrel, supports limits on u/h
* Added mobi
* v6 more tlds
*
* @param str The string to check. (Required)
* @return Returns a boolean.
* @author Jeff Guillaume (SBrown@xacting.comjeff@kazoomis.com)
* @version 6, July 29, 2008
*/
function isEmail(str) {
return (REFindNoCase("^['_a-z0-9-]+(\.['_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*\.(([a-z]{2,3})|(aero|asia|biz|cat|coop|info|museum|name|jobs|post|pro|tel|travel|mobi))$",
arguments.str) AND len(listGetAt(arguments.str, 1, "@")) LTE 64 AND
len(listGetAt(arguments.str, 2, "@")) LTE 255) IS 1;
}
</cfscript>
Search CFLib.org
Latest Additions
Jose Diaz-Salcedo added
cfRssFeed
3 day(s) ago
Raymond Compton added
structBlend
23 day(s) ago
Duncan added
IsZIPUK
23 day(s) ago
Todd Sharp added
getTagContentAll
29 day(s) ago
Gerald Guido added
ListReturnDuplicat...
1 month(s) ago