Validating Form Field Data Types - MACROMEDIA COLDFUSION 5-DEVELOPING Develop Manual

Table of Contents

Advertisement

Validating Data Types
If the variable is not in a valid date format, an error occurs and the page stops
processing.

Validating form field data types

One limitation of standard HTML forms is that you cannot validate that users input
the type or range of data you expect. ColdFusion enables you to do several types of
data validation by adding hidden fields to forms.
The following table describes the hidden field suffixes that you can use to do
validation:
Field Suffix
_integer
_float
_range
_date
_time
_eurodate
Note
Adding a validation rule to a field does not make it a required field. You need to add a
separate
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 illustrates another concept that might seem surprising. You can use
the same CFML page as both a form page and its action page. Because the only
action is to display the values of the two variables that you enter, the action is on the
same page as the form.
Value Attribute
Custom error
message
Custom error
message
MIN=MinValue
MAX=MaxValue
Custom error
message
Custom error
message
Custom error
message
hidden field if you want to ensure user entry.
_required
Description
Verifies that the user entered a number. If the
user enters a floating point value, it is rounded to
an integer.
Verifies that the user entered a number. Does not
do any rounding of floating point values.
Verifies that the numeric value entered is within
the specified boundaries. You can specify one or
both of the boundaries separated by a space.
Verifies that the user entered a date and converts
the date into the proper ODBC date format. Will
accept most common date forms; for example,
9/1/98; Sept. 9, 1998.
Verifies that the user correctly entered a time and
converts the time to the proper ODBC time
format.
Verifies that the user entered a date in a standard
European date format and converts into the
proper ODBC date format.
91

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 5

Table of Contents