Adobe 38043740 - ColdFusion Standard - Mac Development Manual page 754

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

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Requesting and Presenting Information
• Optionally, specify an error message.
• Optionally, specify a validation technique. (By default, ColdFusion uses onSubmit validation.)
The following example specifies onBlur validation of a telephone number:
Phone: <cfinput type="text" name="HPhone"
validateat="onBlur"
validate="required,telephone"
message="Please enter a standard U.S. telephone number with an optional
extension, such as x12345">
The following information describes considerations for validation in
complete example.
Validation type considerations
General considerations: Consider the following issues when you determine how to validate form data:
• When you validate form data using onBlur, onSubmit, onServer, or hidden form field validation, you can specify
one or more validation types for each field that you validate. For example, you can specify that a field entry is
required and that it must be numeric. To specify multiple validation types for onSubmit, onBlur, or onServer
validation, specify the type values in a comma-delimited list.
• If you use onBlur, onSubmit, or onServer type validation, you can specify only one error message for each field that
you validate. If you use hidden field validation, you can create a custom message for each validation rule (except for
range checking).
• In the
tag, most validation type attributes apply only to text or password fields.
cfinput
Validation algorithm differences: The underlying validation code used when validating form data can differ
depending on the validation technique and the form type. As a result, the algorithms used vary in some instances,
including the following:
• The validation algorithms used for date/time values in onSubmit and OnBlur validation are different from those
validation algorithms used for all server-side validation techniques.
• The algorithms used for onSubmit and OnBlur validation in Flash can vary from those algorithms used for HTML
or XML format, and generally follow simpler rules.
For detailed information on the validation algorithms used for validation techniques used on the server, see
"Validating form data using hidden
Validating data in XML skinnable forms
If you create an XML skinnable form and use any skin provided by Adobe, such as the basic.xsl or silver.xsl skin, you
can use all form validation techniques that are available for HTML forms.
If you use a custom skin (XSL file), the available validation techniques depend on the skin. The
cf_webroot\CFIDE\scripts\xsl directory contains a _cfformvalidation.xsl file that implements all ColdFusion HTML
form validation techniques and supports onBlur, onSubmit, onServer, and hidden form field validation. XML skin
writers can include this file in their skin XSLT to implement ColdFusion validation for their skin.
Example: basic form validation
The following form asks for information to use when registering a new user. It checks to make sure that the user enters
required information. (Only the telephone number is optional.) It also checks to make sure that the telephone number
and e-mail address are properly formatted and that the number to use in a challenge question is in the proper range.
This example performs onSubmit validation. It posts back to itself, and dumps the submitted results.
fields" on page 755.
Last updated 1/20/2012
and
tags, and show a more
cfinput
cftextarea
749

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 9

Table of Contents