MACROMEDIA COLFUSION MX 7-GETTING STARTED BUILDING COLDFUSION MX Getting Started page 116

Building coldfusion mx applications
Table of Contents

Advertisement

Modifying the Trip Edit page to use ColdFusion form tags
In this exercise, you use the ColdFusion form tags to move the validation of many business rules
from the server to the client. To do this, you change the HTML form tags in the tripedit.cfm page
to ColdFusion form tags that validate these fields on the client side. Next, you remove the
unneeded server-side single-field validation code from the tripeditaction.cfm page. Finally, you
test the form to ensure that the client-side validation is working correctly.
To use the ColdFusion form tags on the Trip Edit page:
Open the tripedit.cfm file in the my_app directory in your editor.
1.
Locate and change the
2.
Change the
3.
<input>
tags to
<textarea>
Note: The input type for the submit button must remain a standard input rather than cfinput.
For each ColdFusion form tag (
4.
values:
Attribute value
required
validate
message
The following table contains the revised code blocks:
Rule Description
1
All trips must be named.
2
All trips must be
accompanied by a full
description.
3
Each trip must be
categorized by event type.
Only valid event types (1-
surfing, 2-mountain
climbing, and so on) are
permissible.
4
Trip locations are required.
116
Chapter 10: Lesson 7: Validating Data to Enforce Business Rules
and
<form>
</form>
tags to
tags,
<cfinput>
tags.
<cftextarea>
and
cfinput
Description
Use this attribute for fields that must be filled out or selected.
Use this attribute for fields that require a specific data type for validation.
Values include: integer, date, time, telephone, and zip code.
Use this attribute for fields that require an error message to appear if
validation fails. The message reflects the text that describes the business rule.
Validation code
<cfinput name= "tripName"
maxlength = "50" size = "50"
required = "Yes"
message = "Trip name must not be blank">
<cftextarea name="tripDescription"
required="Yes"
message="Trip description must not be blank.">
</cftextarea>
<cfselect size="1" name="eventType"
required="Yes"
message="Type of event must be selected.">
<option value="1" selected>Surfing</option>
<option value="2">Mountain Climbing</option>
<option value="3">Mountain Biking</option>
</cfselect>
<cfinput size="50" name="tripLocation"
required="Yes"
message="Trip location must not be blank.">
tags to
and
<cfform>
</cfform>
tags to
<select>
<cfselect>
), assign the following appropriate
cfselect
tags, respectively.
tags, and

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the COLFUSION MX 7-GETTING STARTED BUILDING COLDFUSION MX and is the answer not in the manual?

Questions and answers

This manual is also suitable for:

Colfusion mx 7 - installing and using coldfusion mx

Table of Contents