Return to Snippet

Revision: 45829
at May 9, 2011 16:16 by nehringryan


Initial Code
<cfloop collection= "#form#"  item="formfield" > 
   <cfset form[formfield] = trim(htmlEditFormat(form[formfield]))>  
</cfloop>

Initial URL
http://ryannehring.com/

Initial Description
A lot of people forget that the FORM scope is just a structure, and as such can be manipulated in all the same ways any other Struct could be... including looping through it with a cfloop collection... below is an example of code you could have at the top of a CFM action page or in a CFC Function to strip out any whitespace/invalid letters from a forms values before using them.

This collection cfloop performs native coldfusion functions htmlEditFormat and trim on each value from the form struct before saving the clean variable back to form.

Initial Title
Auto Trim/Clean Submitted Form Data in Coldfusion

Initial Tags


Initial Language
ColdFusion