ColdFusion's in-built form validation
July 01, 2008
Does anyone actually use ColdFusion's in-built form validation? I don't mind the _cfformxyz suffixes it's the _date, _time, _range and _required suffixes which really bug me. If nobody uses this legacy feature any more can we just get rid of it? A setting in Application.cfc to turn it off would do!
If you haven't stumbled across this feature and the problems it causes then let me give you an example:
<p>New Vacancy Form</p>
<form action="index.cfm" method="post">
<table summary="New vacancy form">
<tr>
<th>Job Title</th>
<td><input type="text" name="job_title" value="" /></td>
</tr>
<tr>
<th>Salary Range</th>
<td><input type="text" name="salary_range" value="" /></td>
</tr>
<tr>
<th>Driving Licence Required</th>
<td><input type="checkbox" name="licence_required" value="Yes" /></td>
</tr>
<tr>
<th>Closing Date</th>
<td><input type="text" name="closing_date" value="" /></td>
</tr>
<tr>
<td colspan="2"><input type="submit" name="submit" value="submit" /></td>
</tr>
</table>
</form>
If you tick the Driving Licence Required box and submit this form, then regardless of what code you have in myscript.cfm you will see this error message:
Form entries are incomplete or invalid.
Yes
Go back and correct the problem.
I have also used in my example reserved field name suffixes, so that could create problems in the future if we add more form fields. For more information on ColdFusion's in-built form validation view the Validating form data using hidden fields on livedocs.
- Posted in:
- ColdFusion
4 comments
Leave a comment
If you found this post useful, interesting or just plain wrong, let me know - I like feedback :)

Comment by dickbob – July 01, 2008
I just find it annoying that you have to be careful when naming your fields so that you don't get caught out by ColdFusion's form validation.
Comment by John Whish – July 01, 2008
Comment by Matt Newby – July 02, 2008
when 8 came out we noticed that they added quite a few more versions that do this
http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=validateData_10.html#1154690
Also, I could be wrong but I thought this performed server side rather than client side javascript validation. I would swear the first time I came across it I was using a browser without javascript.
Comment by Matt – July 03, 2008