We're trying to loop around 10 form fields (to check
if the email addresses is valid), but are having a
problem with the form.fieldname value being passed to
the email format checking code. I set up a list of the
field names and then am looping through that field
list, but the REFindNoCase function doesn't read the
value of the form.fieldname, just the value
"form.fieldname". Is there any way to make this type
of looping work?
Here is the code:
<cfset
fieldlist="mailone,mail2,mail3,mail4,mail5,mail6,mail7,mail8,mail9,mail10">
<CFLOOP LIST="#fieldlist#" INDEX="fname">
<CFIF #fname# IS NOT "">
<cfsetting enablecfoutputonly="yes">
<cfparam name="ReturnCode" default="0">
<cfset sEmailRE =
"^([a-zA-Z0-9\.]+)\@([a-zA-Z0-9\.\-]+)\.([a-zA-Z]{2,3})$">
<cfif ReFindNoCase(sEmailRE,#fname#)>
<cfset ReturnCode = "1">
</cfif>
<cfsetting enablecfoutputonly="no">
<CFIF returncode IS "0">
Error message
<CFELSE>
Continue
</CFIF>
</CFIF>
</CFLOOP>
Thank you for any suggestions!
Mark
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists