• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL

Part II: Creating ColdFusion Forms > Validating Data and Handling Errors

Chapter 7. Validating Data and Handling Errors

When you allow users to use forms to submit information that will be saved in a database, you must make every effort to ensure that the data being saved conforms to your database table specifications. If the data in your database becomes corrupt or inaccurate, users will quickly find another web site to use.

For example, if you create a form that lets users save personal information, a number of form fields are set up to accept the information, such as name, address, social security number, credit card numbers, telephone numbers, and email addresses.

You use ColdFusion logic to validate dynamically the data passed from form pages. Data validation logic can take many forms, including conditional logic like CFIF and CFELSE tags, built-in ColdFusion functions like isNumber and isDefined, and custom functions known as user-defined functions (UDFs). As their name suggests, UDFs are custom functions that you, or other developers, write to perform granular processing tasks, such as data validation.

When you validate data entered by the user and find an error, you should present the user with a descriptive message explaining the error. This is commonly referred to as error handling. Error handling can be as simple as Dreamweaver’s Show Region server behaviors or as complex as specifying custom error templates for individual error types.

In this chapter, you will build two ColdFusion pages: a form page and an action page. In addition, you will download a ColdFusion page from www.cflib.org, which will let you import a library of UDFs.

For more information about using databases, see Chapter 4, “Working with Databases.”



Not a subscriber?

Start A Free Trial

  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint