Using Validators.validateAll() method to validate a form : Form Validator « Components « 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 » Components » Form ValidatorScreenshots 
Using Validators.validateAll() method to validate a form
Using Validators.validateAll() method to validate a form
     
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="initApp()">

    <mx:Script>
        
            import mx.events.ValidationResultEvent;
            import mx.controls.Alert;
            import mx.validators.Validator;

            private var myValidators:Array;

            private function initApp():void {
                myValidators = [valid1, valid2];
            }

            private function clickHandler():void {
                var errors:Array = Validator.validateAll(myValidators);
                if (errors.length == 0) {
                    Alert.show("Looks valid to me.""SUCCESS");
                }
            }
      
    </mx:Script>

    <mx:StringValidator id="valid1" source="{ti1}" property="text" minLength="4" maxLength="6" />
    <mx:StringValidator id="valid2" source="{ti2}" property="text" minLength="4" maxLength="6" enabled="false" />

    <mx:TextInput id="ti1" />
    <mx:TextInput id="ti2" />

    <mx:Button label="validate" click="clickHandler()" />

</mx:Application>

   
    
    
    
    
  
Related examples in the same category
1.Using Flex validators with form modelsUsing Flex validators with form models
2.Set up validator for Form input fieldsSet up validator for Form input fields
3.Use Validator to validate data from a formUse Validator to validate data from a form
4.Validator, Model and Form controlsValidator, Model and Form controls
5.Validating form control contents data on user entryValidating form control contents data on user entry
6.Validate form data with ActionScriptValidate form data with ActionScript
7.Validating user input for form dataValidating user input for form data
8.Change form input box label when data is not validChange form input box label when data is not valid
9.Use ActionScript to validate form dataUse ActionScript to validate form data
10.Validate a date entered into a formValidate a date entered into a form
11.Validate an e-mail address to ensure that it is formatted correctlyValidate an e-mail address to ensure that it is formatted correctly
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.