Adobe 38043740 - ColdFusion Standard - Mac Development Manual page 766

Developing applications
Hide thumbs Also See for 38043740 - ColdFusion Standard - Mac:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Requesting and Presenting Information
}
//-->
</script>
</head>
<body>
<h2>JavaScript validation test</h2>
<!--- Form is submitted only if the password is valid. --->
<cfif IsDefined("Form.passwd1")>
<p>Your Password if valid.</p>
</cfif>
<p>Please enter your new password:</p>
<cfform name="UpdateForm" preservedata="Yes" >
<!--- The onValidate attribute specifies the JavaScript validation
function. The message attribute is the message that appears
if the validation function returns False. --->
<cfinput type="password" name="passwd1" required="YES"
onValidate="testpasswd"
message="Your password must have 8-12 characters and include uppercase
and lowercase letters and at least one number."
size="13" maxlength="12">
<input type="Submit" value=" Update... ">
</cfform>
</body>
</html>
Save the page as validjs.cfm.
2
View the validjs.cfm page in your browser.
3
Handling failed validation
The
attribute lets you specify a JavaScript function to execute if an onValidate, onBlur, or onSubmit
onError
validation fails. For example, if you use the
validation, you can also use the
when
returns a False value). If you use the
onValidate
to specify a JavaScript function that handles the validation errors. The following
attribute:
cfgrid
cfinput
cfselect
cfslider
cftextinput
cftree
ColdFusion passes the following JavaScript objects to the function in the
• The JavaScript form object
• The
attribute of the form element
name
• The value that failed validation
attribute to specify a JavaScript function to handle input
onValidate
attribute to specify a JavaScript function to handle a failed validation (that is,
onError
onValidate
Last updated 1/20/2012
attribute, you can also use the
tags support the
cfform
attribute:
onerror
761
attribute
onError
onerror

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 9

Table of Contents