Development Flex



    
        
            import mx.events.ValidationResultEvent;
            import mx.validators.*;
            
            private var phoneV:PhoneNumberValidator;
            
            private function doValidate():void
            {
                phoneV = new PhoneNumberValidator();
                phoneV.source = phoneTxt;
                phoneV.property = "text";
                phoneV.required = true;
                phoneV.allowedFormatChars = "+,-";
                phoneV.required = true;
                phoneV.allowedFormatChars = "+-";
                phoneV.invalidCharError = "Invalid char.";
                phoneV.wrongLengthError = "Invalid format";
                phoneV.requiredFieldError = "required";
    
                phoneV.trigger = phoneTxt;
                phoneV.triggerEvent = "change";
            }
            
            private function isValid(evt:Event):void
            {
                validationTxt.text  = evt.type as String;
                myLbl.visible = true;
                myLbl.text = "Validated!"
                myLbl.styleName = evt.type;
            }
            
            private function notValid(evt:Event):void
            {               
                validationTxt.text  = evt.type as String;
                myLbl.visible = true;
                myLbl.text = "Correct the error in this field !"
                myLbl.styleName = "invalid";
            }
            private function handleResultEvent(evt:ValidationResultEvent):void {
                
                if(evt.type==ValidationResultEvent.VALID)  
                {
                    validationTxt.text  = "The FormItem has been succesfully validated !";
                    
                }  else if(evt.type==ValidationResultEvent.INVALID) 
                {
                    validationTxt.text  = "The FormItem has NOT been validated !";
                }
            }
      
    

     
        .invalid {
         color:#FF0000;
        }
        .valid {
            color:#004000;
        }