Chapter 10: Building Dynamic Forms
Input Validation with JavaScript
In addition to native ColdFusion input validation using the VALIDATE attribute of the
CFINPUT and CFTEXTINPUT tags, the following tags support the ONVALIDATE
attribute , which allows you to specify a JavaScript function to handle your CFFORM
input validation:
CFINPUT
CFSLIDER
CFTEXTINPUT
CFTREE
JavaScript objects passed to the validation routine
The following JavaScript objects are passed by ColdFusion to the JavaScript function
you specify in the ONVALIDATE attribute:
form_object
input_object
object_value
Handling failed validation
The ONERROR attribute allows you to specify a JavaScript function you want to
execute in the event of a failed validation. For example, if you specify a JavaScript
function to handle input validation in the ONVALIDATE attribute you can also specify
a JavaScript function in the ONERROR attribute to handle a failed validation, which
returns a false value. ONERROR is available in the following CFFORM tags:
CFINPUT
CFSELECT
CFSLIDER
CFTEXTINPUT
CFTREE
When you specify a JavaScript routine in the ONERROR attribute, ColdFusion passes
the following JavaScript objects to the specified routine:
form_object
input_object
object_value
error message text
127
Need help?
Do you have a question about the COLDFUSION 4.5-DEVELOPING WEB and is the answer not in the manual?