MACROMEDIA COLDFUSION 5-DEVELOPING Develop Manual page 113

Table of Contents

Advertisement

Validating Data Types
3
4
When the user submits the form, ColdFusion scans the form fields to find any
validation rules you specified. The rules are then used to analyze the user's input. If
any of the input rules are violated, ColdFusion sends an error message to the user
that explains the problem. The user then must go back to the form, correct the
problem. and resubmit the form. ColdFusion does not accept form submission until
the user enters the entire form correctly.
Because numeric values often contain commas and dollar signs, these characters are
automatically deleted from fields with
are validated and saved to a database.
Reviewing the code
The following table describes the code and its function:
Code
<form action="actionpage.cfm"
<input type="hidden"
<input type="hidden"
<input type="hidden"
<input type="hidden"
Start Date:
<input type="text"
</cfoutput>
</cfif>
</html>
Save the file as datatest.cfm.
View the file in your browser, omit a field or enter invalid data, and click the
Submit button.
method="post">
name="StartDate_required"
value="You must enter a start date.">
name="StartDate_date"
value="Enter a valid date as the
start date.">
name="Salary_required"
value="You must enter a salary.">
name="Salary_float"
value="The salary must be a number.">
name="StartDate" size="16"
maxlength="16"><br>
,
, or
_integer
_float
Description
Gather the information from this form
using the Post method, and do
something with it on the page
dataform.cfm, which is this page.
Require input into the StartDate input
field. If there is no input, display the error
information "You must enter a start
date." Require the input to be in a valid
date format. If the input is not valid,
display the error information "Enter a
valid date as the start date."
Require input into the Salary input field.
If there is no input, display the error
information "You must enter a salary."
Require the input to be in a valid
number. If it is not valid, display the error
information "The salary must be a
number."
Create a text box called StartDate in
which users can enter their starting date.
Make it exactly 16 characters wide.
rules before they
_range
93

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 5

Table of Contents