From ColdFusion Cookbook:
Trimming is an essential part of dealing with an data coming from form textfields or textareas etc. You can of couse trim as and when you need (before validation or database inserts etc) but if you can trim all fields quickly and easily!
<cfloop collection="#form#" item="formfield"> <cfset form[formfield] = trim(form[formfield]) /> </cfloop>
This basically loops over a form structure and trims each element. You can use this loop in a function before handing it to your validation or database methods.