User Guide

Table Of Contents
659
CHAPTER 28
Validating Data
This chapter explains how to validate data in Macromedia ColdFusion MX. It focuses on
validating form data, but also contains information on how you can validate variable data and
function parameters.
Contents
About ColdFusion MX validation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 659
Validating form fields. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 667
Handling invalid data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 669
Masking form input values. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 670
Validating form data with regular expressions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 671
Validating form data using hidden fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 675
Validating form input and handling errors with JavaScript. . . . . . . . . . . . . . . . . . . . . . . . . . . 680
Validating data with the IsValid function and the cfparam tag . . . . . . . . . . . . . . . . . . . . . . . . 683
About ColdFusion MX validation
Data validation lets you control data that is entered into an application by ensuring that the data
conforms to specific type or formatting rules. Validation techniques have the following features:
They let you provide feedback to users so that they can immediately correct information they
provide. For example, a form can provide immediate feedback when a user enters a name in a
telephone number field, or the form could force the user to enter the number in the correct
format.
They help prevent application errors that might arise when processing invalid data. For
example, a validation test can prevent a variable that is used in a calculation from having
nonnumeric data.
They can help enhance security by preventing malicious users from providing data that takes
advantage of system security weaknesses, such as buffer overrun attacks.