Chapter 6. Validating user input
This chapter covers
- Validation versus enforcement
- Pass-through validation
- Committed-value validation
- Scripted and real-time validation
Conducting client-side validation is a key strength of Flex. From a usability point of view, you want your application to do as much prevalidation as possible. This helps to avoid aggravating situations in which a user spends a fair amount of time filling out a large form and then clicks the submit button, only to find something is wrong with the input.
This is exactly the sort of thing that prevents an application from being fluid. In the HTML environment, JavaScript handles some data validation. How many times have you filled out a form, only to find out the username you’ve picked just happens to be taken?
Wouldn’t it be nice to have all the validation done prior to submitting a form to avoid wasting time? Flex to the rescue! Flex provides a real-time validation mechanism that unobtrusively accomplishes that goal.
In this chapter, we look at how Flex handles validation and the different types of validators, such as those that verify the proper formatting of phone numbers and the structure of email addresses. Then we put them to use, employing several different approaches.
First, let’s get a sense of Flex’s approach to validation.