Use DateValidator to validate and use DateForamtter to format : DateValidator « Data Model « Flex

Home
Flex
1.Chart
2.Components
3.Container
4.Data Model
5.Development
6.Effects
7.Event
8.Graphics
9.Grid
10.Style
Flex » Data Model » DateValidator 




Use DateValidator to validate and use DateForamtter to format
Use DateValidator to validate and use DateForamtter to format
     
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" minWidth="1024" minHeight="768">
        <mx:DateFormatter id="dateFormatter" formatString="day: DD, month: MM, year: YYYY"/>
        <mx:DateValidator id="dateVal" inputFormat="mm/dd/yyyy"/>
    <mx:Script>
        
            import mx.events.ValidationResultEvent;
            private var vResult:ValidationResultEvent;
            private function dateFormat():void
            {
                vResult = dateVal.validate(inputDate.text);
                if (vResult.type==ValidationResultEvent.VALID) {
                    inputDate.text = dateFormatter.format(inputDate.text);
                else {
                    inputDate.text= "";
                }
            }
      
    </mx:Script>
        <mx:Label text="Date Input"/>
        <mx:TextInput id="inputDate" focusOut="dateFormat();" width="300"/>
</mx:Application>

   
    
    
    
    
  














Related examples in the same category
1.Use Submit button to trigger validationUse Submit button to trigger validation
2.Set trigger event for DateValidatorSet trigger event for DateValidator
3.Set source and input format for DateValidatorSet source and input format for DateValidator
4.Bind DateValidator to more than one controlsBind DateValidator to more than one controls
5.Set up input format for DateValidatorSet up input format for DateValidator
6.DateValidator and form input boxesDateValidator and form input boxes
7.Validate a Date objectValidate a Date object
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.