Adobe COLDFUSION 9 Manual page 760

Developing applications
Hide thumbs Also See for COLDFUSION 9:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Requesting and Presenting Information
Expression
[\?&]value=
^[A-Z]:(\\[A-Z0-9_]+)+$
^(\+|-)?[1-9][0-9]*$
^(\+|-)?[1-9][0-9]*(\.[0-9]*)?$
^(\+|-)?[1-9]\.[0-9]*E(\+|-)?[0-9]+$
a{2,4}
(ba){2,}
Note: An excellent reference on regular expressions is Mastering Regular Expressions by Jeffrey E.F. Friedl, published by
O'Reilly & Associates, Inc.
Validating form data using hidden fields
ColdFusion lets you specify form field validation on the server by using hidden form fields whose names consist of the
name of the field to validate and the validation type. Hidden field validation uses the same underlying techniques and
algorithms as onServer validation of ColdFusion form fields.
Hidden field validation has the following features:
• You can use it with standard HTML tags. For example, you can validate data in an HTML
was useful in releases previous to ColdFusion MX 7, because the
attributes.
• It is backward-compatible with validation previous to ColdFusion MX 7, when hidden field validation was the only
way to do validation on the server.
• Because you use a separate tag for each validation type, if you specify multiple validation rules for a field, you can
specify a different error message for each rule.
• You can use hidden field validation with any form field type that submits a data value, not
, or
textarea
cftextarea.
Specifying hidden form field validation
To specify hidden field validation, you do the following:
• Create one HTML
input
• Specify the name of the field to validate as the first part of the hidden field name.
• Specify the type of validation, starting with an underscore character (_), as the second part of the hidden field name.
• You can specify multiple rules for each form data field. For example, to specify range and required validation for a
field named myValue, create hidden myValue_cfformrange and myValue_cfformrequired fields.
• For most types of validation, specify the error message as the field
• For range, maximum length, or regular expression validation, specify the rule, such as the maximum length, in the
attribute. For these validation types, you cannot specify a custom error message.
value
The following example uses hidden fields to require data in a date field and ensure that the field contains a date. It
consists only of HTML tags.
Description
Any string containing a URL parameter value.
An uppercase Windows directory path that is not the root of a drive and has only letters,
numbers, and underscores in its text.
An integer that does not begin with a zero and has an optional sign.
A real number.
A real number in engineering notation.
A string containing two to four occurrences of a: aa, aaa, aaaa; for example, aardvark, but not
automatic.
A string containing least two ba pairs; for example, Ali baba, but not Ali Baba.
element or CFML
tag of
cfinput
Last updated 8/5/2010
tag did not support all HTML
cfinput
for each validation rule.
type="hidden"
attribute.
value
755
tag. This feature
input
type
,
,
input
cfinput

Advertisement

Table of Contents
loading

Table of Contents