Popa Mihai

PopaMihai.com – Flex, Flash, AIR and ActionScript articles and tutorials

Archive for the ‘Validators’ tag

How to Trigger a Flex Validator From a Keyboard Event and From a Text Event

2 comments

Flex Validators have two properties that you can use to trigger the validator using any kind of events:

The trigger property specifies the component that is generating the event that will triggers the validator. If you don’t specify this property Flex will use the the source property.

The triggerEvent property is used to specify the event that will trigger the validator.
Read the rest of this entry »

Written by Popa Mihai

July 30th, 2009 at 1:20 pm

Posted in Flex

Tagged with , , ,

Example of using the ZipCodeValidator Class in Flex

one comment

The ZipCodeValidator class is used to check if the user input corresponds to the zip code format.
Here is the syntax for this class:

<mx:zipcodevalidator allowedFormatChars=" -" 
     domain="US Only | US or Canada"
     invalidCharError="The ZIP code contains invalid characters." 
     invalidDomainError="The domain parameter is invalid. It must be either 'US Only' or 'US or Canada'." 
     wrongCAFormatError="The Canadian ZIP code must be formatted 'A1B 2C3'." 
     wrongLengthError="The ZIP code must be 5 digits or 5+4 digits." 
     wrongUSFormatError="The ZIP+4 extension must be formatted '12345-6789'."></mx:zipcodevalidator>

Read the rest of this entry »

Written by Popa Mihai

July 30th, 2009 at 12:10 am

Posted in Flex

Tagged with , , ,

Example of using the SocialSecurityValidator Class in Flex

one comment

SocialSecurityValidator expects a string of digits in the format “NNN-NN-NNNN”. When using the SocialSecurityValidator you can specify the separator. By default, the separator can be a dash or a space.

<mx:socialsecurityvalidator allowedFormatChars=" -"
     invalidCharError="You entered invalid characters in your Social Security number."
     wrongFormatError="The Social Security number must be 9 digits or in the form NNN-NN-NNNN."
     zeroStartError="Invalid Social Security number: the number cannot start with 000."></mx:socialsecurityvalidator>

Read the rest of this entry »

Written by Popa Mihai

July 29th, 2009 at 11:36 pm

Example of using the PhoneNumberValidator Class in Flex

one comment

The PhoneNumberValidator validator checks if the text enterered by the user represents a phone number or not.

Here is the syntax of the PhoneNumberValidator Flex Validator:

<mx:phonenumbervalidator allowedFormatChars="()- .+" 
      invalidCharError="Invalid characters in your phone number." 
      wrongLengthError="Your telephone number must be at least 10 digits in length."></mx:phonenumbervalidator>

Read the rest of this entry »

Written by Popa Mihai

July 29th, 2009 at 10:59 pm

Example of using the CurrencyValidator Class in Flex

one comment

CurrencyValidator is a Flex Validator that ensures that the text entered by the user represents a valid currency expression.

You can set a minimum value (minValue) and a maximum value (maxValue), you can specify if the amount is negative or not by setting the allowNegative parameter.

Here is a simple example that demonstrates the CurrencyValidator:

Read the rest of this entry »

Written by Popa Mihai

July 29th, 2009 at 10:50 pm

Posted in Flex

Tagged with , , ,

Example of using the CreditCardValidator Class in Flex

one comment

The CreditCardValidator Flex Validator takes two parameters to be set by the user. The first one is the credit card type and the second one is the credit card number. The credit card type can have 5 values:

  • Visa
  • MasterCard
  • Discover
  • American Express
  • Diners Club

Here is an example that demonstrates how to use the CreditCardValidator Flex Validator:
Read the rest of this entry »

Written by Popa Mihai

July 29th, 2009 at 10:13 pm

Example of using the EmailValidator Class in Flex

3 comments

The EmailValidator in Flex verifies if a string is an formatted as an email address. The only parameters you can change to the EmailValidator are the error messages that the user receives when the validation found a problem.

Here is the syntax of the EmailValidator:

<mx:emailvalidator invalidCharError="Invalid characters in your email address." 
	invalidDomainError= "The domain in your email address is incorrectly formatted." 
	invalidIPDomainError="The IP domain in your email address is incorrectly formatted." 
	invalidPeriodsInDomainError="The domain in your email address has consecutive periods." 
	missingAtSignError="Missing an at character in your email address." 
	missingPeriodInDomainError="The domain in your email address is missing a period." 
	missingUsernameError="The username in your email address is missing." 
	tooManyAtSignsError="Too many at characters in your email address."></mx:emailvalidator>

Here is an example that checks if a string entered by the user is an email or not:

Read the rest of this entry »

Written by Popa Mihai

July 29th, 2009 at 9:15 pm

Posted in Flex

Tagged with , , ,

Example of using the DateValidator Class in Flex

one comment

The DateValidator helps you validate if the user input is a date or not.

Here is an example that uses the DateValidator Flex Class to validate the text typed in a textinput:
Read the rest of this entry »

Written by Popa Mihai

July 29th, 2009 at 9:05 pm

Posted in Flex

Tagged with , , ,

Example of using the NumberValidator Class in Flex

one comment

The NumberValidator is another built in Flex Validator that you can use to validate if a value is a number or not. Here is the syntax for the NumberValidator:
Read the rest of this entry »

Written by Popa Mihai

July 29th, 2009 at 7:48 pm

Posted in Flex

Tagged with , , ,

Example of using the StringValidator Class in Flex

one comment

The StringValidator class is used to simply to validate strings.

The StringValidator class inherits all the attributes of its parent Class, the Validator Class and adds these 4 new tag attributes:
Read the rest of this entry »

Written by Popa Mihai

July 29th, 2009 at 6:51 pm

Posted in Flex

Tagged with , , ,