O'Reilly logo

Programming ColdFusion by Rob Brooks-Bilson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Data Validation

One of the big benefits of using CFFORM over standard HTML forms is the built-in data validation that is available. Both the CFINPUT and CFTEXTINPUT tags have an attribute called VALIDATE that accepts any of the following values:

CreditCard

Validates the form field data using the mod10 algorithm. Credit-card numbers can be entered as a single number or with dashes or spaces. ColdFusion automatically strips dashes and spaces before validating.

Date

Requires the form-field value to be in the U.S. date format mm/dd/yyyy.

EuroDate

Requires the form-field value to be in the European date format dd/mm/yyyy.

Float

Requires the form-field value to be a floating-point number.

Integer

Requires the form-field value to be an integer.

Social_Security_Number

Requires the form-field value to be a U.S. social security number in the format xxx-xx-xxxx or xxx xx xxxx.

Telephone

Requires the form-field value to be a U.S. telephone number formatted either xxx-xxx-xxxx or xxx xxx xxxx. The area code and exchange are required to begin with a number in the range of 1-9.

Time

Requires that the form-field value be entered as a valid time using the format hh:mm:ss.

ZipCode

Requires that the form-field value be entered as either a five- or nine-digit U.S. ZIP code using the format xxxxx, xxxxx-xxxx, or xxxxx xxxx.

In addition to the VALIDATE attribute, the CFINPUT and CFTEXTINPUT tags as well as the CFGRID, CFSLIDER, and CFTREE tags support an additional attribute for ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required