Adobe 38043740 - ColdFusion Standard - Mac Development Manual page 756

Developing applications
Hide thumbs Also See for 38043740 - ColdFusion Standard - Mac:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Requesting and Presenting Information
3
For HTML and XML format forms (using ColdFusion skins), most ColdFusion form tags have an
attribute that lets you specify a Javascript function to run if an onSubmit error occurs.
For the
function, you write separate code paths to handle valid and invalid data. The following example
4
IsValid
shows a simplified case that displays an error message if the user entered an invalid e-mail address, or a different
message if the address is valid:
<cfif IsValid("email", custEmail)>
Thank you for entering a valid address.
<!--- More processing would go here. --->
<cfelse>
You must enter a valid e-mail address.<br>
Click the Back button and try again.
</cfif>
For
and
5
cfparam
cfargument
tag in a
block and use a
try
following example form action page code uses a custom error page, expresserr.cfm, to handle the error that the
tag generates if a user submits a form with an invalid e-mail address:
cfparam
<cferror type="EXCEPTION" exception="expression" template="expresserr.cfm">
<cfif IsDefined("form.fieldnames")>
<cfparam name="form.custEmail" type="email">
<!--- Normal form processing code goes here. --->
</cfif>
Masking form input values
The
tag
attribute controls the format of data that can be entered into a
cfinput
mask
You can also use a mask attribute in the
• In HTML and Flash form format, a mask can control the format of data entered into a
• In the
tag, and, for Flash format forms, the
cfcalendar
format of the date that ColdFusion uses for the date a user chooses in the displayed calendar.
Note: The standard ColdFusion XML skins do not support masking.
Masking text input
In text fields, ColdFusion automatically inserts literal mask characters, such as - characters in telephone numbers.
Users type only the variable part of the field. You can use the following characters to mask data:
Mask character
A
X
9
?
All other characters
The following pattern enforces entry of a part number of the format EB-1234-c1-098765, where the user starts the
entry by typing the first numeric character, such as 1. ColdFusion fills in the preceding EB prefix and all hyphen (-)
characters. The user must enter four numbers, followed by two alphanumeric characters, followed by six numbers.
<cfinput type="text" name="newPart" mask="EB-9999-XX-999999" />
tags, you use standard ColdFusion error-handling techniques. You can include the
block to handle the error, or you can use a custom error-handling page. The
catch
tag. You can combine masking and validation on a field.
cfcalendar
Effect
Allows an uppercase or lowercase character: A–Z and a–z.
Allows an uppercase or lowercase character or number: A–Z, a–z, and 0–9.
Allows a number: 0–9.
Allows any character.
Automatically inserts the literal character.
Last updated 1/20/2012
text
type
field, a mask can control the
datefield
cfinput
onError
or
input field.
datefield
field.
text
751

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 9

Table of Contents