News and Views
Sunday, December 11, 2005 1:46:51 PM
ColdFusion provides several decent validation techniques. One of the easiest to implement was using hidden form fields -- for every field you want validated, include a hidden field with the same name with an underscore followed by the validation type. For example, to validate a required text field named "firstname" you would add a hidden field named "firstname_required". It was not 100% secure, but quick-and-easy to implement for non-critical data. Server-side validation using hidden fields seems to be broken in CF 7. This works in CF 6:
<cfset tast = form.checkbox>
<form id="form1" name="form1" method="post" action="">
<input type="text" name="textfield" />
<input type="checkbox" name="checkbox" value="checkbox" />
<input type="hidden" name="checkbox_required" value="Must check box" />
<input type="submit" name="Submit" value="Submit" />
In CF 6.1 and earlier, if you fail to check the box, CF will issue a controlled validation error message "Must check box". In CF 7, CF fails and errors out: "Element CHECKBOX is undefined in FORM." I've filed a bug on it, but I wonder how many exisiting applications are failing because of this feature. I had to rewrite a few things to take the bug into account, since I am running the site on CF 7 now.
Category tags: ColdFusion
Before posting comments or trackbacks, please read the posting policy.