O'Reilly logo

Flash 8 Cookbook by Joey Lott

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

14.6. Validating Form Data

Problem

You want to validate form data before allowing the user to submit it to a server-side script.

Solution

Use the built-in data validation features of the FormController component.

Discussion

Data validation can be an important feature to include in your Flash forms. Often you may have required fields in a form that you want users to fill out before submitting the form data. If they don’t fill out the form fields, you’ll want to prompt them for that information before allowing them to continue. Furthermore, you may also want to verify that the data being entered matches certain criteria. For example, you may want to make sure that the value entered into a field looks like a valid email address. Or you may want to make sure that users have entered a valid number value.

Although you can write your own data validation scripts, it can require quite a lot of ActionScript code, and it is beyond the scope of this book. However, the FormController component (discussed in Chapter 13) provides built-in data validation features. Using the FormController component, you can make particular form elements required, and you can also verify that entered values match particular patterns such as email or number.

In order to use the data validation features, there are two requirements. You must include a component that can display any messages to the user in your Flash document’s library, and you must specify the Validator and Message values in the FormController’s elements ...

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