O'Reilly logo

Adobe ColdFusion 8 Web Application Construction Kit, Volume 1: Getting Started by Charlie Arehart, Raymond Camden, Ben Forta

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using <cfparam> Server-Side Validation

One solution to the proliferation of <cfif> statements in Listing 13.2 is to use the <cfparam> tag (first introduced in Chapter 9, “Programming with CFML”). The <cfparam> tag has two distinct functions:

  • Providing default values for variables

  • Performing field value validation

The difference is whether or not a default is provided. Look at this example:

<cfparam name="LoginID">

No default value is provided, and so LoginID is required, and if not present an error will be thrown.

By contrast, this next example has a default value:

<cfparam name="color" default="red">

In this example color isn’t required, and if not present, the default value of red will be used.

<cfparam> also supports one additional attribute, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required