Adobe 38043740 - ColdFusion Standard - Mac Development Manual page 755

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

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Requesting and Presenting Information
<cfif IsDefined("form.fieldnames")>
<cfdump var="#form#"><br>
</cfif>
<cfform name="myform" preservedata="Yes" >
First Name: <cfinput type="text" size="15" name="firstname"
required="yes" message="You must enter a first name."><br>
Last Name: <cfinput type="text" size="25" name="lastname"
required="yes" message="You must enter a last name."><br>
Telephone: <cfinput type="text" size="20" name="telephone"
validate="telephone" message="You must enter your telephone
number, for example 617-555-1212 x1234"><br>
E-mail: <cfinput type="text" size="25" name="email"
validate="email" required="Yes"
message="You must enter a valid e-mail address."><br>
Password:<cfinput type="password" size="12" name="password1"
required="yes" maxlength="12"
message="You must enter a password."><br>
Reenter password:<cfinput type="password" size="12" name="password2"
required="yes" maxlength="12"
message="You must enter your password twice."><br>
We will ask you for the following number, in the range 100-999 if you forget
your password.<br>
Number: <cfinput type="text" size="5" name="chalenge"
validate="range" range="100,999" required="Yes"
message="You must enter a reminder number in the range 100-999."><br>
<cfinput type="submit" name="submitit">
</cfform>
Handling invalid data
How you handle invalid data depends on the validation type. The information here describes validation error-
handling rules and considerations. For detailed information on error handling in ColdFusion, including invalid data
handling, see
"Handling
Errors" on page 275.
For onBlur, onSubmit, or onServer validation, you can use the
1
specify a text-only error message to display. Otherwise, ColdFusion uses a default message that includes the name
of the form field that was invalid. (For OnServer validation, you can customize this message, as described in
"Handling form field validation
user enters an invalid e-mail address:
E-mail: <cfinput type="text" size="25" name="email"
validate="email" message="You must enter a valid e-mail address.">
2
For hidden form validation, you can specify a text-only error message in the hidden field's
Otherwise, ColdFusion uses a default message that includes the name of the form field that was invalid. (You can
customize this message, as described in
tag, for example, uses a hidden field validation to display an error message if the user enters an invalid
cfinput
address. (It uses onServer validation to display a different error message if the user fails to enter a number.)
Telephone: <cfinput type="text" size="20" name="telephone"
validateat="onServer" required="Yes"
message="You must enter a telephone number">
<cfinput type="hidden" name="telephone_cfformtelephone"
value="The number you entered is not in the correct format.<br>Use a
number such as (617) 555-1212, 617-555-1212, or 617-555-1212 x12345">
errors" on page 282.) The following example displays an error message when the
"Handling form field validation
Last updated 1/20/2012
or
tag's
cfinput
cftextarea
errors" on page 282.) The following
750
attribute to
message
attribute.
value

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 9

Table of Contents