Input validation with cfform controls

The cfinput and cftextinput tags include the validate attributes, which lets you specify a valid data entry type for the control. You can validate user entries on the following data types:

Data type Description

Date

Verifies US date entry in the form mm/dd/yyyy (where the year can have one through four digits).

Eurodate

Verifies valid European date entry in the form dd/mm/yyyy (where the year can have one through four digits).

Time

Verifies a time entry in the form hh:mm:ss.

Float

Verifies a floating point entry.

Integer

Verifies an integer entry.

Telephone

Verifies a telephone entry. You must enter telephone data as ###-###-####. You can replace the hyphen separator (-) with a blank. The area code and exchange must begin with a digit between 1 and 9.

Zipcode

(U.S. formats only) Number can be a five-digit or nine-digit zip in the form #####-####. You can replace the hyphen separator (-) with a blank.

Creditcard

Blanks and dashes are stripped and the number is verified using the mod10 algorithm.

Social_security_number

You must enter the number as ###-##-####. You can replace the hyphen separator (-) with a blank.

Regular_expression

Matches the input against a JavaScript regular expression pattern. You must use the pattern attribute to specify the regular expression. Any entry containing characters that matches the pattern is valid.

When you specify an input type in the validate attribute, ColdFusion tests for the specified input type when you submit the form, and submits form data only on a successful match. A successful form submission returns the value True and returns the value False if validation fails.

View comments on LiveDocs