|
Mailing Lists
|
Home /
Groups /
New York ColdFusion Users Group (NYCFUG)
Server Sided Email Validation Routine?
Author: Dave Carabetta
Short Link: http://www.houseoffusion.com/groups/nycfug/thread.cfm/threadid:748#2162
----- Excess quoted text cut - see Original Post for more -----
Not a problem. Glad it helped!
Regards,
Dave.
Author: Robert Harrison
Short Link: http://www.houseoffusion.com/groups/nycfug/thread.cfm/threadid:748#2161
> Dave Carabetta Wrote:
<cffunction name="isEmail" returntype="boolean" access="public"
output="false" hint="I test passed value to see if it is a valid e-mail
address (supports subdomain nesting and new top-level domains).">
<cfargument name="str" type="string" required="true" hint="I am
the string to test." />
<cfscript>
var isOK = false;
//supports new top level tlds
if (
REFindNoCase("^['_a-z0-9-]+(\.['_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*\.
(([a-z]{2,3})|(aero|coop|info|museum|name))$",
arguments.str) ) {
isOK = true;
}
return isOK;
</cfscript>
</cffunction>
Yup. That works great. Thank you.
Robert B. Harrison
Director of Interactive Services, Ext. 205
155 East Main Street
Smithtown, NY 11787
P (631) 361-4400
F (631) 361-6400
http://www.linx.com
Author: Dave Carabetta
Short Link: http://www.houseoffusion.com/groups/nycfug/thread.cfm/threadid:748#2160
----- Excess quoted text cut - see Original Post for more -----
I use this e-mail validator method in our UDF CFC and it works great.
Watch for wrapping:
<cffunction name="isEmail" returntype="boolean" access="public"
output="false" hint="I test passed value to see if it is a valid
e-mail address (supports subdomain nesting and new top-level
domains).">
<cfargument name="str" type="string" required="true" hint="I am the
string to test." />
<cfscript>
var isOK = false;
//supports new top level tlds
if (
REFindNoCase("^['_a-z0-9-]+(\.['_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*\.(([a-z]{2,3})|(aero|coop|info|museum|name))$",
arguments.str) ) {
isOK = true;
}
return isOK;
</cfscript>
</cffunction>
Hope this helps.
Regards,
Dave.
Author: Robert Harrison
Short Link: http://www.houseoffusion.com/groups/nycfug/thread.cfm/threadid:748#2159
Problem Summary:
User can enter email addresses to a data base through a form. Most are
validated properly by java script on client side, but a few users don't
have java script and they enter incorrect syntax in an email addresses.
The bad email address goes into the data base and when a CFMAIL is
processed against a query loop it chokes and hard fails on the first
incorrect mail address format it encounters.
Possible Solutions:
I see a couple possible solutions:
1. On an MX7 server I could use the new IsValid tag in the loop,
however, the site is not on an MX7 server, it's on MX6. Bummer.
2. If there was some way to make CFMAIL not choke on bad email
addresses and just process through them that would be fine, but I can
see no way to override the halt.
3. If there was a script to validate on the server side I could use
it. I found a custom tag an macro media site which does do server side
validation for email at:
http://www.macromedia.com/cfusion/exchange/index.cfm?view=sn131&extID=10
24332#loc=en_us&view=sn131&extID=1024332&viewName=ColdFusion%20Extension
&avm=1 but the download gives a 404 error.
HELP NEEDED:
Bottom line is I need to either: 1) validate the format of an email
address and, if it will not choke CFMAIL, let it run, or 2) tell CFMAIL
not to halt and continue on when it gets a bad mail address.
Does anyone know of a solution for this problem?
Thanks,
Robert B. Harrison
Director of Interactive Services, Ext. 205
Linx Communications
155 East Main Street
Smithtown, NY 11787
P (631) 361-4400
F (631) 361-6400
http://www.linx.com <http://www.linx.com/>
|
May 25, 2012
|
Latest Fusion Authority Articles
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||