Data Model Flex



    
        
            import mx.controls.Alert;
            import mx.events.ValidationResultEvent;
            import mx.validators.PhoneNumberValidator;
            
            private var phoneV:PhoneNumberValidator;
            private var phoneVResult:ValidationResultEvent;
            private var nameVResult:ValidationResultEvent;
            private function doValidate():void
            {
                phoneV = new PhoneNumberValidator();
                phoneV.source = myModel;
                phoneV.property = "phone";
                phoneV.listener=phoneTxt;
                phoneV.required = true;
                phoneV.allowedFormatChars = "+,-";
                phoneV.invalidCharError = "Insert valid chars";
                phoneV.wrongLengthError = "The number is too short or too long";
                phoneV.requiredFieldError = "This input is required";
                phoneVResult = phoneV.validate();
                
                if(phoneVResult.type==ValidationResultEvent.VALID)  
                {
                    Alert.show("Validated!", "Validation Message", 4);
                        
                }  else if(phoneVResult.type==ValidationResultEvent.INVALID) 
                {
                    Alert.show("NOT validated !", "Validation Message", 4);
                }
            }
          
    

    
         
         {nameTxt.text}
         {surnameTxt.text}
         {phoneTxt.text}