Using Flex validators with form models : Form Validator « Components « Flex






Using Flex validators with form models

Using Flex validators with form models
     

<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
    <mx:Script>
        
        private function processValues():void {
            var myZipCode:String = myFormModel.zipCodeModel;
            var myPhoneNumber:String = myFormModel.phoneNumberModel;
        }
      
    </mx:Script>
    <mx:Model id="myFormModel">
        <info>
            <zipCodeModel>{zipCode.text}</zipCodeModel>
            <phoneNumberModel>{phoneNumber.text}</phoneNumberModel>
        </info>
    </mx:Model>
    <mx:ZipCodeValidator source="{myFormModel}" property="zipCodeModel" trigger="{zipCode}" listener="{zipCode}" />
    <mx:PhoneNumberValidator source="{myFormModel}" property="phoneNumberModel" trigger="{b1}" listener="{phoneNumber}" triggerEvent="click" />
    <mx:Form borderStyle="solid">
        <mx:FormItem label="Zip Code">
            <mx:TextInput id="zipCode" />
        </mx:FormItem>
        <mx:FormItem label="Phone Number">
            <mx:TextInput id="phoneNumber" />
        </mx:FormItem>
        <mx:FormItem>
            <mx:Button id="b1" label="Submit" click="processValues();" />
        </mx:FormItem>
    </mx:Form>
</mx:Application>

   
    
    
    
    
  








Related examples in the same category

1.Set up validator for Form input fieldsSet up validator for Form input fields
2.Use Validator to validate data from a formUse Validator to validate data from a form
3.Validator, Model and Form controlsValidator, Model and Form controls
4.Using Validators.validateAll() method to validate a formUsing Validators.validateAll() method to validate a form
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