Steven,

This may help.  I pasted it from a presentation I wrote to give to some
staff programmers recently, so please excuse the semi-formal language.

<snip>
Form validation via cold fusion

CF includes an easy way to validate your forms, called �Cold Fusion embedded
form validation�.  The syntax is passed to the cf server via a
normal-looking <input type=hidden> scheme.

Suppose you have a field called Lastname.  It is in your form thus:
        <input type=�text� name=�Lastname� size=�20� maxlength=�50�>

To make this field required, add the following hidden field:
        <input type=�hidden� name=�Lastname_required� value=�Enter your last name.�
>

This tells the cf engine that the field Lastname is required, and if a form
is submitted without that field, the error message �Enter your last name.�
shows on the screen.

There are many validation checks at your disposal.  The list includes:
_date : Checks for a date in the most common formats
_float : Numeric data, decimal point allowed
_integer : Numeric data, no decimal point allowed
_range : Range of values, as in �min=5  max=10�
_required : Field may not be left blank
_time : Time in most common formats

There is no limit to the number of validation rules you can embed in a form.
Every rule must be embedded as a separate Hidden field, however.  So to flag
a field as both numeric and required, for example, you�d need 2 hidden
fields.
</snip>

Hope that helps,

Douglas Malcolm




-----Original Message-----
From: Steven A. del Sol [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 03, 2001 3:04 PM
To: CF-Talk
Subject: Simple validation


I am in desperate need of a simple validation of two types of form fields.

1.   Date field (not a cfform just a plain form) - must validate that data
entered is a date

2.  Number field (not a cfform just a plain form) - must validate that data
entered is a number


Thanks

Stephanie
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to