> Does anyone have a routine to parse and validate e-mail addresses in a
text
> area?
>
> I'm having some trouble figuring out all the necessary steps.
>
> It would be cool if it could handle various delimiters (spaces, commas,
etc)
> and validate each address, resulting in a simple comma delimited list of
> valid (format) addresses.
Watch the linefeeds, as it may come out on the list a little differently.
This is off the top of my head, and has not been tested, but it's a place to
start.
<!--- Need to have somewhere to start. --->
<cfset variables.emails = "This would be your textarea of addresses.">
<!--- Change spaces to commas. --->
<cfset variables.emails = listchangedelims(variables.emails, ",", " ")>
<cfscript>
// Remove CR's and LF's.
variables.emails = replace(variables.emails, chr(13), ",");
variables.emails = replace(variables.emails, chr(10), ",");
// Start our counter.
variables.lcounter = 1;
</cfscript>
<!--- Loop over the list and eliminate bad e-mail addresses. --->
<cfloop list=#variables.emails# index="address"><cfscript>
// If it's not a decent format...
if (not
refindnocase("^[[:alnum:]]([[:alnum:]_\.\-]*[[:alnum:]])?@([[:alnum:]]([[:al
num:]\-]*[[:alnum:]])?*\.)+([a-z][a-z]|[a-z][a-z][a-z]|[a-z][a-z][a-z][a-z]|
[a-z][a-z][a-z][a-z][a-z])$", variables.address)) {
// Eliminate it.
variables.emails = listdeleteat(variables.emails, variables.counter);
}
// Increment our counter.
variables.lcounter = variables.lcounter + 1;
</cfscript></cfloop>
-Justin Scott, Lead Developer
Sceiron Internet Services, Inc.
http://www.sceiron.com
----- Original Message -----
From: "Jeff Beer" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Thursday, October 25, 2001 11:35 AM
Subject: validate email addresses in text area
>
> Thank in advance!
>
> Jeff
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists