Tom Muck's Blog: Problem with ColdFusion validation
News and Views
Problem with ColdFusion validation
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:
<cfif isdefined("form.textfield")>
<cfset tast = form.checkbox>
</cfif>
<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" />
</form>
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
Posted by Tom Muck
Add comment |
View comments (0) |
Permalink
|
Trackbacks (0)
|
Digg This
Before posting comments or trackbacks, please read the posting policy.