DateValidator in Flex4


 

DateValidator in Flex4

The DateValidator class validates the string and date format. You can enter the single or two digit for month and day.

The DateValidator class validates the string and date format. You can enter the single or two digit for month and day.

DateValidator in Flex4:

The DateValidator class validates the string and date format. You can enter the single or two digit for month and day. By default the DateValidator class takes the following range for day, month and year.

1. The month range between 1 to 12.
2. The day range between 1 to 31.
3. The year range is a four digit number.
The tag of DateValidator is <mx:DateValidator>.
You can use the allowedFormatChars property for specify a character between day, month and year like slash (/), backslash (\), dash (-), and period (.).

Example:

 <?xml version="1.0" encoding="utf-8"?>

<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"

minWidth="955" minHeight="600">

<fx:Script>

<![CDATA[

import mx.controls.Alert;

]]>

</fx:Script>

<fx:Declarations>

<fx:Model id="CheckDate">

<dateInfo>

<Date>{date.text}</Date>

</dateInfo>

</fx:Model>

<mx:DateValidator source="{date}" property="text"

 allowedFormatChars="/"

trigger="{btn}" triggerEvent="click"

valid="Alert.show('Validation Successful');"/>

</fx:Declarations>

<s:Panel title="DateValidator Example" width="550">

<mx:Form height="94" width="548" backgroundColor="#101446"

 color="#FFFFFF">

<mx:FormItem label="Enter Date(mm/dd/yyyy): ">

<s:TextInput id="date" width="100%" color="#000000"/>

</mx:FormItem>

<mx:FormItem >

0

<s:Button id="btn" label="Check Validation" chromeColor="#5F1B0C"/>

</mx:FormItem>

</mx:Form>

1

</s:Panel>

</s:Application>

Output:

2

Running Application:

To view this page ensure that Adobe Flash Player version 10.0.0 or greater is installed.


Download this code

Ads