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>