Chapter 13. Validating and Formatting Data


Many applications collect information from users phone numbers, email addresses, and so on for later use, or to send to a database where it can be stored and retrieved as needed. However, if these applications trusted users to enter properly formatted, error-free information, they probably wouldn't function properly that, or your database would quickly fill with useless data. The fact is, users often enter data incorrectly which is why it's a good idea to validate data before it's used or processed. Validating data usually entails writing a script to check the way data was entered against a set of guidelines or rules. If data-entry errors are found, the user can be prompted to reenter the data, or (in some cases) the script can make the needed adjustments without further input from the user.

Our fictional product contains a product registration form that allows us to collect data from the user, validate it, and display any errors found.

graphics/13fig01.gif

In this lesson, we'll create an application that includes a form requiring user-input data that needs to be validated. After our application validates this information, it will display a custom confirmation page a common way of thanking the user for providing the requested information.

WHAT YOU WILL LEARN

In this lesson, you will:

  • Learn why validation is important

  • Define validation requirements

  • Set up a method to handle errors found in the validation process

  • Create functions for validating strings, numbers, and sequences

  • Format dynamic data using HTML

  • Create text fields dynamically

  • Format text using TextFormat objects

APPROXIMATE TIME

This lesson takes approximately 2 hours to complete.

LESSON FILES

Media Files:

None

Starting File:

Lesson13/Assets/validate1.fla

Lesson13/Assets/flashWriter1.fla

Completed Project:

validate7.fla

flashWriter3.fla



Macromedia Flash MX ActionScripting Advanced. Training from the Source
Macromedia Flash MX ActionScripting: Advanced Training from the Source
ISBN: 0201770229
EAN: 2147483647
Year: 2002
Pages: 161

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net