/ Published in: ColdFusion
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.
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.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<cfloop collection= "#form#" item="formfield" > <cfset form[formfield] = trim(htmlEditFormat(form[formfield]))> </cfloop>