Archive for the 'Validators' Category

31
Aug

Validating negative numbers using the NumberValidator in Flex

The following example shows how you can prevent or allow negative numbers when using the NumberValidator class by setting the Boolean allowNegative property.

Full code after the jump.

Continue reading ‘Validating negative numbers using the NumberValidator in Flex’

30
Aug

Validating integers using the NumberValidator class

The following example shows how you can validate a number as an integer or real (floating point) number by setting the domain property on a NumberValidator instance.

Full code after the jump.

Continue reading ‘Validating integers using the NumberValidator class’

29
Aug

Validating email addresses using the EmailValidator class in Flex

The following example shows you how you can validate email addresses in a Flex application using the EmailValidator class and the validate() and static EmailValidator.validateEmail() methods.

Full code after the jump.

Continue reading ‘Validating email addresses using the EmailValidator class in Flex’

13
Mar

Validating strings using the StringValidator class

The following example shows how you can validate strings using the static StringValidator.validateString() method.

Full code after the jump.

Continue reading ‘Validating strings using the StringValidator class’

25
Aug

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’

13
Aug

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’

02
Aug

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’