User Guide

Table Of Contents
Validating form data with regular expressions 671
Masking cfcalendar and datefield input
In the
cfcalendar tag and the Flash format datefield input control, you use the following
masks to determine the format of the output. You can use uppercase or lowercase characters in
the mask:
The following pattern specifies that the Flash forms sends the date selected using a
datefield
input control to ColdFusion as text in the format 04/29/2004:
<cfinput name="startDate" type="datefield" label="date:" mask="mm/dd/yyyy"/>
Validating form data with regular expressions
You can use regular expressions to match and validate the text that users enter in cfinput and
cftextinput tags. Ordinary characters are combined with special characters to define the match
pattern. The validation succeeds only if the user input matches the pattern.
Regular expressions let you check input text for a wide variety of custom conditions for which the
input must follow a specific pattern. You can concatenate simple regular expressions into complex
search criteria to validate against complex patterns, such as any of several words with different
endings.
You can use ColdFusion variables and functions in regular expressions. The ColdFusion server
evaluates the variables and functions before the regular expression is evaluated. For example, you
can validate against a value that you generate dynamically from other input data or database
values.
Note: The rules listed in this section are for JavaScript regular expressions, and apply to the regular
expressions used in
cfinput and cftextinput tags only. These rules differ from those used by the
ColdFusion functions
REFind, REReplace, REFindNoCase, and REReplaceNoCase. For information on
regular expressions used in ColdFusion functions, see Chapter 7, “Using Regular Expressions in
Functions,” on page 141.
Mask Pattern
D Single- or double-digit day of month, such as 1 or 28
DD Double-digit day of month, such as 01 or 28
M Single- or double-digit month, such as 1 or 12
MM Double-digit month, such as 01 or 12
MMM Abbreviated month name, such as Jan or Dec
MMMM Full month name, such as January or December
YY Two-character year, such as 05
YYYY Four-character year, such as 2005
E Single-digit day of week, in the range 0 (Sunday)–6 (Saturday)
EEE Abbreviated day of week name, such as Mon or Sun
EEEE Full month day of week name, such as Monday or Sunday