System information
103
CHAPTER 10
Lesson 7: Validating Data to Enforce
Business Rules
In this lesson, you will create a page for the trip coordinator to add new trip offerings and update
existing trips. In addition, you will add logic to validate that data entered so that it complies with
Compass Travel business rules.
This lesson contains the following exercises:
Exercise 1: Using an HTML form to collect data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
Exercise 2: Creating a simple action page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
Exercise 3: About data validation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
Exercise 4: Providing server-side validation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
Exercise 5: Validating data on the client using ColdFusion form tags . . . . . . . . . . . . . . . . . . . 114
Exercise 6: Dynamically populating the list of event types . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
Exercise 7: Validating the existence of the trip photo file . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
ColdFusion tags and functions introduced in this lesson
The following table describes the ColdFusion tags and functions that you use in this lesson to
enhance the ColdFusion application:
Element Type Description
cfform
Tag Builds a form with CFML custom control tags that provide more
functionality than standard HTML form input elements.
cfinput
Tag Use inside the cfform tag to place radio buttons, check boxes, or text
boxes. Provides input validation for the specified control type.
cfselect
Tag Use inside the cfform tag. Lets you construct a drop-down list form control.
You can populate the drop-down list from a query, or use the HTML
option
tag. You also use
option elements to populate lists. The syntax for the
option tag is the same as for its HTML counterpart.
FileExists
Function Returns True if the file specified in the argument exists, False if it doesn’t
exist.