Validating forms in coldfusion

One limitation of standard HTML forms is that you cannot validate that users input the type or range of data you expect.

Cold Fusion enables you to do several types of data validation by adding hidden fields to forms.

They are passed through Cold Fusion to the browser when creating a form.

The supported HTML attributes are: CLASS, ID, MAXLENGTH, MESSAGE, ONBLUR, ONCHANGE, ONCLICK, ONDBLCLICK, ONFOCUS, SIZE, STYLE, and TABINDEX.

If used, the Passes one or more arbitrary attribute-value pairs to the HTML code that is generated for the tag.

You can use either of the following formats to include the quotation marks around the attribute value: attribute.

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 the user enters a floating point value, it is rounded to an integer.

Cold Fusion 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 Require input into the Start Date 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.

attribute behavior: if it is set to True, Cold Fusion checks radio and check box values only if their value matches the posted value for the control.

Leave a Reply