Data validation types

The following table lists the types of data you can validate when you use most ColdFusion validation techniques. It does not include mask validation. Some validation types are not available for all techniques; in these cases the table indicates the limitations. The onBlur and onSubmit validation algorithms for Flash forms can vary from the validation algorithms described in the following table, and most commonly have less functionality. The asterisk (*) in the Type field column indicates that the field is required. For more detailed descriptions of the onServer validation algorithms, see the table in Validating form data using hidden fields.

Type field

Description

date

When validating on the server, allows any date/time format that returns true in the IsDate function, including a time value. When validating on the client, same as USdate.

USdate *

A U.S. date of the format mm/dd/yy, with 1- or 2-digit days and months, and 1-through 4-digit years. The separators can be slash (/), hyphen (-), or period (.) characters

eurodate *

A date of the format dd/mm/yy, with 1- or 2-digit days and months, and 1- through 4-digit years. The separators can be slash (/), hyphen (-), or period (.) characters.

time *

When validating on the server, allows any date/time format that returns True in the IsDate function, including a date value. When validating on the client, allows a time of format hh:mm[:ss] [A/PM].

float *

A number; allows integers. When validating form fields on the server, integer values are converted to real numbers.

numeric

A number; allows integers. When validating form fields on the server, integer values are unchanged.

integer *

An integer.

range *

A numeric range specified by a range attribute or max and min attributes.

boolean

A value that can be converted to a Boolean value: Yes, No, True, or False (all case-independent), or a number.

telephone *

Standard U.S. telephone formats. Allows an initial 1 long-distance designator and up to 5-digit extensions, optionally starting with x.

zipcode *

U.S. 5- or 9-digit ZIP code format #####-####. The separator can be a hyphen (-) or a space.

creditcard *

Strips blanks and dashes; verifies number using mod10 algorithm. The number must have 13–16 digits.

ssn * or social_security_number *

US. Social Security number format, ###-##-####. The separator can be a dash (-) or a space.

email *

A valid e-mail address of the form name@server.domain. ColdFusion validates the format only; it does not check that entry is a valid active e-mail address.

URL *

A valid URL pattern; supports http, https, ftp file, mailto, and news URLs.

guid *

A unique identifier that follows the Microsoft/DCE format, xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx, where x is a hexadecimal number.

uuid *

A universally unique identifier (UUID) that follows the ColdFusion format, xxxxxxxx-xxxx-xxxx-xxxxxxxxxxxxxxxx, where x is a hexadecimal number.

regex * or regular_expression *

Matches the value against a regular expression specified in a pattern attribute. Valid in HTML and XML format only; ignored in Flash format.

Note: For more details on how ColdFusion handles data when it does onServer and hidden field validation, see Validating form data using hidden fields.

The following validation types can only be used in cfinput tags:

Type

Description

maxlength

Limits the input to a maximum number of characters specified by a maxlength attribute.

noblanks

Does not allow fields that consist only of blanks. ColdFusion uses this validation only if the required attribute is True.

SubmitOnce

Used only with cfformsubmit and image types; prevents the user from submitting the same form multiple times before until the next page loads, Use this attribute, for example, to prevent a user from submitting an order form a second time before getting the confirmation for the initial order, and thereby making a duplicate order, Valid in HTML and XML format only; ignored in Flash format.

You can use the following validation types in cfparam and cfargument tags and the IsValid function only:

Type

Description

any

Any type of value

array

An array of values

binary

A binary value

query

A query object

string

A string value or single character

struct

A structure

variableName *

A string formatted according to ColdFusion variable naming conventions.