I noticed I forgot to put my trim()'s in my form inputs for an admin area, and 
dreaded coding them all in. Cause there's lotsa forms. 

So I did this up and it seems to work well: 

<!--- Output dirty fields --->
 <cfloop list="#FORM.fieldnames#" index="thisfield">
  <cfoutput>#FORM[thisfield]#</cfoutput><br />
 </cfloop>
    <!--- Clean all formfields --->
    <cfloop list="#FORM.fieldnames#" index="thisfield">
     <cfset FORM[thisfield] = Trim(FORM[thisfield])>
    </cfloop>
  <!--- Output clean fields --->
  <cfloop list="#FORM.fieldnames#" index="thisfield">
   <cfoutput>#FORM[thisfield]#</cfoutput><br />
  </cfloop>
  <cfabort>

I can run that right before my inserts, and bingo, done! I guess you could turn 
it into a cfc, send in the form, send it back out cleaned, maybe do more types 
of cleaning than just trim(). 

Anyway, thought I'd share. It seems quite a bit easier than coding in the 
trim()s. I've tried to think of some gotchas and none come to mind. 

Will

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Create Web Applications With ColdFusion MX7 & Flex 2. 
Build powerful, scalable RIAs. Free Trial
http://www.adobe.com/products/coldfusion/flex2/

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:271695
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to