Because numeric values often contain commas and dollar signs, these characters are automatically
deleted from fields with
the data is passed to the form's action page.
Reviewing the code
The following table describes the code and its function:
Code
<form action="datatest.cfm"
method="post">
<input type="hidden"
name="StartDate_required"
value="You must enter a start date.">
<input type="hidden"
name="StartDate_date"
value="Enter a valid date as the
start date.">
<input type="hidden"
name="Salary_required"
value="You must enter a salary.">
<input type="hidden"
name="Salary_float"
value="The salary must be a number.">
Start Date:
<input type="text"
name="StartDate" size="16"
maxlength="16"><br>
Salary:
<input type="text"
name="Salary"
size="10"
maxlength="10"><br>
<cfif isdefined("Form.StartDate")>
<cfoutput>
Start Date is:
#DateFormat(Form.StartDate)#<br>
Salary is:
#DollarFormat(Form.Salary)#
</cfoutput>
</cfif>
,
, or
_integer
_float
rules before the form field is validated and
_range
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.
Create a text box called Salary in which users can
enter their salary. Make it exactly ten characters
wide.
Output the values of the StartDate and Salary form
fields only if they are defined. They are not defined
until you submit the form, so they do not appear on
the initial form. Use the
display the start date in the default date format.
Use the
DollarFormat
salary with a dollar sign and commas.
Validating form field data types
DateFormat
function to
function to display the
581
Need help?
Do you have a question about the COLDFUSION MX 61-DEVELOPING COLDFUSION MX and is the answer not in the manual?
Questions and answers