Category Archives: Validators

Using the ZipCodeValidator class to validate US or Canadian zip codes (redux)

In a previous example, “Using the ZipCodeValidator class to validate US or Canadian zip codes”, we saw how you could validate US or US/Canadian zip codes using the Flex ZipCodeValidator class.

The following example shows how you can use the new “Canada only” zip code validator domain type to ensure users only enter a Canadian postal code.

This example requires Flex SDK 3.2.0.3349 or later. To download the latest version of the Flex SDK, see http://opensource.adobe.com/…/flexsdk/Downloads/.

Full code after the jump.

Continue reading Using the ZipCodeValidator class to validate US or Canadian zip codes (redux)

Using the ZipCodeValidator class to validate US or Canadian zip codes

The following example shows how you can use the ZipCodeValidator to validate either US or Canadian zip codes (or should that be “postal codes” for our friends from the Great White North?). It turns out that making the ZipCodeValidator “Canadian friendly” is as simple as setting the domain property, and passing a constant value from the ZipCodeValidatorDomainType class (valid constants are US_ONLY and US_OR_CANADA).

Full code after the jump.

Continue reading Using the ZipCodeValidator class to validate US or Canadian zip codes

Validating Flex forms using the Validator classes

Another quick post on validating a form using the StringValidator, NumberValidator, ZipCodeValidator and Validator classes. Not sure if this is the best method, but I used the NumberValidator to validate that a ComboBox has a valid selection (the selectedIndex property was equal to or greater than 0), and I used a combination of StringValidator and ZipCodeValidator to make sure that the user enters a US Zip+4 zip code.

Got some good Flex Validator tips? Leave em in the comments!

Full code after the jump.

Continue reading Validating Flex forms using the Validator classes

Using the Validators.validateAll() method to validate a form

I recently saw this issue in FlexCoders and filed a bug for the poster. Well, it turns out the bug I filed was a duplicate of an existing bug, and that bug has been fixed (in Flex 3 — codename:Moxie). So, long story longer, here’s how you can use the Validator class’s validateAll() method to validate a form (which may or may not have enabled validators).

Full code (and workaround) after the jump.

Continue reading Using the Validators.validateAll() method to validate a form