Package | mx.validators |
Classe | public class DateValidator |
Héritage | DateValidator ![]() ![]() ![]() |
Version du langage: | ActionScript 3.0 |
Version du produit: | Flex 3 |
Versions du moteur d’exécution: | Flash Player 9, AIR 1.1 |
- Le mois est compris entre 1 et 12 (ou 0-11 pour les objets
Date
). - Le jour est compris entre 1 et 31.
- L’année est un nombre.
Vous pouvez spécifier la date dans la classe DateValidator de deux manières :
- Une seule classe String contenant la date - Utilisez les propriétés
source
etproperty
pour spécifier la classe String. La classe Chaîne peut contenir des chiffres et les caractères de formatage spécifiés par la propriétéallowedFormatChars
, qui incluent les caractères "/\-.". Par défaut, le format d’entrée de la date dans un champ String est « MM/DD/YYYY », « MM » correspondant au mois, « DD » au jour et « YYYY » à l’année. Vous pouvez utiliser la propriétéinputFormat
pour spécifier un format différent. - Objet
Date
. - Champs Object ou champs multiples contenant le jour, le mois et l’année. Utilisez l’ensemble des propriétés suivantes pour spécifier le jour, le mois et l’année :
daySource
,dayProperty
,monthSource
,monthProperty
,yearSource
etyearProperty
.

The <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" />
Propriétés publiques
Propriété | Défini par |
---|
Propriétés protégées
Méthodes publiques
Méthode | Défini par |
---|
Méthodes protégées
Méthode | Défini par |
---|
Evénements
Constantes protégées
Détails de la propriété
Détails du constructeur
Détails de la méthode
Exemples Comment utiliser cet exemple
DateValidatorExample.mxml
<?xml version="1.0" encoding="utf-8"?> <!-- Simple example to demonstrate the DateValidator. --> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx"> <fx:Script> import mx.controls.Alert; </fx:Script> <fx:Declarations> <fx:Model id="CheckModel"> <dateInfo> <DOB>{dob.text}</DOB> </dateInfo> </fx:Model> <mx:DateValidator source="{dob}" property="text" allowedFormatChars="/" trigger="{myButton}" triggerEvent="click" valid="Alert.show('Validation Succeeded!');"/> </fx:Declarations> <s:Panel title="DateValidator Example" width="75%" height="75%" horizontalCenter="0" verticalCenter="0"> <mx:Form left="10" right="10" top="10" bottom="10"> <mx:FormItem label="Enter date of birth (mm/dd/yyyy): "> <s:TextInput id="dob" width="100%"/> </mx:FormItem> <mx:FormItem > <s:Button id="myButton" label="Validate" /> </mx:FormItem> </mx:Form> </s:Panel> </s:Application>
Tue Jun 12 2018, 09:30 AM Z