THE LOGIC BEHIND VALIDATING DATA


Every day we validate things from words in a sentence (to make sure they make sense) to change received from purchases. Thus, the concept is a natural and easy one for us to understand. Take the following phone number: 555-34567

Chances are, you quickly recognized the above phone number to be invalid. How? Your brain analyzed the phone number and noted that it contained eight numbers. After comparing this fact to the rule that defines valid local phone numbers as those that include seven numbers, your brain made a determination of true (the number was valid) or false (it was invalid). If you determine that the above number is valid, you can place the phone call. If, however, the number is invalid, your brain will log an error message something like "That number is wrong. I need to get the correct number and then try to call."

graphics/13fig02.gif

If we were to break down the validation process, it would look like the following:

  • Define criteria for valid data.

  • Analyze submitted data.

  • Compare this data against defined criteria.

  • Continue if data is valid; determine and note error if data is invalid, resolve, then try again.

In ActionScript, this process of analyzing information, comparing it to a set of rules, and then determining the data's validity is known as a validation routine. Just as your brain analyzes data instantaneously, an ActionScript validation routine takes just a split second to complete.

You usually need to validate data within a Flash application whenever you require the user to enter information into an input-text field for example, on forms (name, address, phone number, and so on), in passwords, on quizzes (to verify answers), and in e-commerce shopping carts (quantities, sizes, colors, and so on).



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