<mx:DateValidator>
tag
inherits all of the tag attributes of its superclass,
and adds the following tag attributes:
<mx:DateValidator allowedFormatChars="/\-. " dayListener="Object specified by daySource" dayProperty="No default" daySource="No default" formatError= "Configuration error: Incorrect formatting string." inputFormat="MM/DD/YYYY" invalidCharError="The date contains invalid characters." monthListener="Object specified by monthSource" monthProperty="No default" monthSource="No default" validateAsString="true|false" wrongDayError="Enter a valid day for the month." wrongLengthError="Type the date in the format inputFormat." wrongMonthError="Enter a month between 1 and 12." wrongYearError="Enter a year between 0 and 9999." yearListener="Object specified by yearSource" yearProperty="No default" yearSource="No default" />]]>
Vous pouvez spécifier la date dans la classe DateValidator de deux manières :
Vous n’appelez pas cette méthode directement ; Flex l’appelle dans le cadre d’une validation. Si vous créez une classe Validator personnalisée, vous devez implémenter cette méthode.
<mx:ZipCodeValidator>
tag
inherits all of the tag attributes of its superclass,
and adds the following tag attributes:
<mx:ZipCodeValidator allowedFormatChars=" -" domain="US Only | US or Canada | Canada Only" invalidCharError="The ZIP code contains invalid characters." invalidDomainError="The domain parameter is invalid. It must be either 'US Only', 'Canada Only', or 'US or Canada'." wrongCAFormatError="The Canadian postal code must be formatted 'A1B 2C3'." wrongLengthError="The ZIP code must be 5 digits or 5+4 digits." wrongUSFormatError="The ZIP+4 code must be formatted '12345-6789'." />]]>
Vous n’appelez pas cette méthode directement ; Flex l’appelle dans le cadre d’une validation. Si vous créez une classe Validator personnalisée, vous devez implémenter cette méthode.
Dans ActionScript, vous pouvez utiliser les constantes suivantes pour définir cette propriété :
Cette interface permet de valider plusieurs types de données, tels que des nombres, des devises, des numéros de téléphone, des codes postaux, etc., qui sont définis dans les espaces de noms mx et spark. Les classes mx:Validator et spark:GlobaliationValidatorBase implémentent cette interface. La méthode validateAll() dans ces classes utilise ce type d’interface pour appeler la méthode validate() sur plusieurs objets de programme de validation.
Si cette valeur est définie sur
<mx:CurrencyValidator>
tag
inherits all of the tag properties of its superclass,
and adds the following tag properties:
<mx:CurrencyValidator alignSymbol="left|right|any" allowNegative="true|false" currencySymbol="$" currencySymbolError="The currency symbol occurs in an invalid location." decimalPointCountError="The decimal separator can occur only once." decimalSeparator="." exceedsMaxError="The amount entered is too large." invalidCharError="The input contains invalid characters." invalidFormatCharsError="One of the formatting parameters is invalid." lowerThanMinError="The amount entered is too small." maxValue="NaN" minValue="NaN" negativeError="The amount may not be negative." precision="2" precisionError="The amount entered has too many digits beyond the decimal point." separationError="The thousands separator must be followed by three digits." thousandsSeparator="," />]]>
Vous n’appelez pas cette méthode directement ; Flex l’appelle dans le cadre d’une validation. Si vous créez une classe Validator personnalisée, vous devez implémenter cette méthode.
<mx:StringValidator>
tag
inherits all of the tag attributes of its superclass,
and add the following tag attributes:
<mx:StringValidator maxLength="NaN" minLength="NaN" tooLongError="This string is longer than the maximum allowed length. This must be less than {0} characters long." tooShortError="This string is shorter than the minimum allowed length. This must be at least {0} characters long." />]]>
Vous n’appelez pas cette méthode directement ; Flex l’appelle dans le cadre d’une validation. Si vous créez une classe Validator personnalisée, vous devez implémenter cette méthode.
<mx:RegExpValidator>
tag
inherits all of the tag attributes of its superclass,
and adds the following tag attributes:
<mx:RegExpValidator expression="No default" flags="No default" noExpressionError="The expression is missing." noMatchError="The field is invalid." />]]>
La validation réussit si le programme de validation trouve une correspondance de l’expression régulière dans le champ à valider. Une erreur de validation se produit si le programme de validation ne trouve aucune correspondance.
La classe RegExpValidator distribue les événements
Cependant, pour un événement
Vous n’appelez pas cette méthode directement ; Flex l’appelle dans le cadre d’une validation. Si vous créez une classe Validator personnalisée, vous devez implémenter cette méthode.
<mx:NumberValidator>
tag
inherits all of the tag attributes of its superclass,
and adds the following tag attributes:
<mx:NumberValidator allowNegative="true|false" decimalPointCountError="The decimal separator can only occur once." decimalSeparator="." domain="real|int" exceedsMaxError="The number entered is too large." integerError="The number must be an integer." invalidCharError="The input contains invalid characters." invalidFormatCharsError="One of the formatting parameters is invalid." lowerThanMinError="The amount entered is too small." maxValue="NaN" minValue="NaN" negativeError="The amount may not be negative." precision="-1" precisionError="The amount entered has too many digits beyond the decimal point." separationError="The thousands separator must be followed by three digits." thousandsSeparator="," />]]>
Vous n’appelez pas cette méthode directement ; Flex l’appelle dans le cadre d’une validation. Si vous créez une classe Validator personnalisée, vous devez implémenter cette méthode.
Dans le langage ActionScript, vous pouvez utiliser les constantes suivantes pour définir cette propriété :
<mx:PhoneNumberValidator>
tag
inherits all of the tag attributes of its superclass,
and adds the following tag attributes:
<mx:PhoneNumberValidator allowedFormatChars="()- .+" invalidCharError="Your telephone number contains invalid characters." minDigits="10" wrongLengthError="Your telephone number must contain at least 10 digits." />]]>
En général, vous n’appelez pas cette méthode directement ; Flex l’appelle dans le cadre d’une validation. Si vous créez une classe Validator personnalisée, vous devez implémenter cette méthode.
<mx:EmailValidator>
tag
inherits all of the tag attributes of its superclass,
and adds the following tag attributes:
<mx:EmailValidator invalidCharError="Your e-mail address contains invalid characters." invalidDomainError= "The domain in your e-mail address is incorrectly formatted." invalidIPDomainError="The IP domain in your e-mail address is incorrectly formatted." invalidPeriodsInDomainError="The domain in your e-mail address has consecutive periods." missingAtSignError="An at sign (&64;) is missing in your e-mail address." missingPeriodInDomainError="The domain in your e-mail address is missing a period." missingUsernameError="The username in your e-mail address is missing." tooManyAtSignsError="Your e-mail address contains too many &64; characters." />]]>
Vous pouvez utiliser des noms de domaines IP s’ils sont entourés de crochets ; par exemple, monnom@[206.132.22.1]. Vous pouvez utiliser des nombres IP compris entre 0 et 255.
Vous n’appelez pas cette méthode directement ; Flex l’appelle dans le cadre d’une validation. Si vous créez une classe Validator personnalisée, vous devez implémenter cette méthode.
Cependant, pour un événement
La classe ValidationResultEvent définit l’objet d’événement qui est transmis aux écouteurs d’événements pour les événements de classe Validator
<mx:Validator enabled="true|false" listener="Value of the source property" property="No default" required="true|false" requiredFieldError="This field is required." source="No default" trigger="Value of the source property" triggerEvent="valueCommit" />]]>
Si vous créez une sous-classe d’une classe Validator, vous devez remplacer cette méthode.
Cet événement est distribué lorsque vous définissez la propriété
Les sous-classes doivent remplacer cette méthode et, après avoir appelé la méthode
Les sous-classes de la classe Validator qui valident plusieurs champs de données (par exemple, CreditCardValidator et DateValidator) doivent assigner cette propriété dans leur constructeur.
Si vous ne spécifiez aucun écouteur, Flex utilise la valeur de la propriété
<mx:CreditCardValidator>
tag
inherits all of the tag attributes of its superclass,
and adds the following tag attributes:
<mx:CreditCardValidator allowedFormatChars=" -" cardNumberListener="Object specified by cardNumberSource" cardNumberProperty="No default" cardNumberSource="No default" cardTypeListener="Object specified by cardTypeSource" cardTypeProperty="No default" cardTypeSource="No default" invalidCharError= "Invalid characters in your credit card number. (Enter numbers only.)" invalidNumberError="The credit card number is invalid." noNumError="No credit card number is specified." noTypeError="No credit card type is specified or the type is not valid." wrongLengthError="Your credit card number contains the wrong number of digits." wrongTypeError="Incorrect card type is specified." />]]>
Vous pouvez spécifier l’entrée dans la classe CreditCardValidator de deux manières :
Dans MXML, utilisez les valeurs :
Dans ActionScript, utilisez les constantes statiques
Pour procéder à la validation, les instructions suivantes sont observées :
Durée:
Vous n’appelez pas cette méthode directement ; Flex l’appelle dans le cadre d’une validation. Si vous créez une classe Validator personnalisée, vous devez implémenter cette méthode.
Dans MXML, les valeurs possibles sont les suivantes :
Dans ActionScript, vous pouvez utiliser les constantes suivantes pour définir cette propriété :
<mx:SocialSecurityValidator>
tag
inherits all of the tag attributes of its superclass,
and adds the following tag attributes:
<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." />]]>
Vous n’appelez pas cette méthode directement ; Flex l’appelle dans le cadre d’une validation. Si vous créez une classe Validator personnalisée, vous devez implémenter cette méthode.
Vous gérez en général les événements
Vous pouvez utiliser la propriété
Pour effacer l’erreur de validation, écrivez une chaîne vide, "", dans la propriété
Ecrire une valeur dans la propriété