
757
DEVELOPING
COLDFUSION 9 APPLICATIONS
Requesting and Presenting Information
Las
t
upda
te
d 8/5/2010
Hidden form field considerations
Consider the following rules and recommendations when determining whether and how to use hidden form field
validation:
•
Use hidden field validation if you want to validate data from standard HTML
input
tags. The
cfinput
and
cftextarea
tags include a
validateAt
attribute that provides a simpler method for specifying server-side
validation.
•
Consider using hidden field validation with the
cfinput
and
cftextarea
tags if you specify multiple validation
rules for a single field and want to provide a separate error message for each validation.
•
Do not use the suffixes listed in the table as field names.
•
Adding a validation rule to a field does not make it a required field. Add a separate
_required
hidden field to
ensure user entry.
Hidden form field example
The following procedure creates a simple form for entering a start date and a salary. It uses hidden fields to ensure that
you enter data and that the data is in the right format.
This example uses a self-submitting form; the same ColdFusion page is both the form page and its action page. The
page uses an
IsDefined
function to check that form data has been submitted. This way, the pages does not show any
results until you submit the input. The form uses HTML tags only; you can substitute these tags with the CFML
equivalents.
_cfformURL
A valid URL. Must start with http:\\, https:\, ftp:\, file:\, mailto:, or news:. Can include, as appropriate,
user name and password designators and query strings. The main part of the address can only have
the characters A-Za-z0-9 and -.
_cfformboolean
A value that can be treated as a Boolean: Yes, No, True, False, 0, 1.
_cfformUUID
A universally unique identifier (UUID) that follows the ColdFusion format, xxxxxxxx-xxxx-xxxx-
xxxxxxxxxxxxxxxx, where x is a hexadecimal number.
_cfformGUID
A unique identifier that follows the Microsoft/DCE format, xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx,
where x is a hexadecimal number.
_cfformnoblanks
The field must not include blanks. ColdFusion uses this validation only if you also specify a
_
required
hidden field.
_cfformmaxlength
The number of characters must not exceed the number specified by the tag
value
attribute.
_cfformregex,
_cfformregular_expression
The data must match a JavaScript regular expression specified by the tag
value
attribute.
_required, _cfformrequired
Data must be entered or selected in the form field.
Field name suffix
Verifies