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.
- <cfloop collection= "#form#" item="formfield" >
- <cfset form[formfield] = trim(htmlEditFormat(form[formfield]))>
You need to login to post a comment.