Cheers that's sort of how I've done it, but it just seems a bit much to have (in my case) 10 separate validators when if I'm using a model I should only need one custom validator. If you follow the livedocs example it would seem ridicules if you can validate multiple fields using one validator but you can only highlight the error around one of the input boxes when you can have several.
There is nothing wrong in the below solution, but it just doesn't sit well with me that I'm having to use several validators when one should do. Thanks Kenneth. ________________________________ From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Manish Jethani Sent: 23 April 2007 22:22 To: flexcoders@yahoogroups.com Subject: Re: REPSOST: [flexcoders] validating multiple fields Here's how I would do it: <mx:Model id="person"> <name> <custName> <first>{firstInput.text}</first> <middle>{middleInput.text}</middle> <last>{lastInput.text}</last> </custName> </name> </mx:Model> <mx:TextInput id="firstInput"/> <mx:TextInput id="middleInput"/> <mx:TextInput id="lastInput"/> <mx:Validator source="{person}" property="custName.first" listener="{firstInput}" trigger="{btn}" triggerEvent="click" required="true" /> <mx:Validator source="{person}" property="custName.middle" listener="{middleInput}" trigger="{btn}" triggerEvent="click" required="true" /> <mx:Validator source="{person}" property="custName.last" listener="{lastInput}" trigger="{btn}" triggerEvent="click" required="true" /> <mx:Button id="btn" label="Validate" /> So you basically have separate validators for each of the fields and they all get triggered on the button click. On 4/23/07, Kenneth Sutherland <[EMAIL PROTECTED] <mailto:ksutherland%40inpses.co.uk> > wrote: > > > > > Not sure if this wasn't answered as it's a bit difficult or because I posted > it on a Friday J so I'm giving it another go, this time on a Monday. > > Cheers. > > > > ________________________________ > > > From: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> [mailto:flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> ] On > Behalf Of Kenneth Sutherland > Sent: 13 April 2007 16:05 > To: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> > Subject: [flexcoders] validating multiple fields > > > > > > > > I've been following this example on livedocs > > http://livedocs.adobe.com/flex/2/docs/wwhelp/wwhimpl/common/html/wwhelp. htm?context=LiveDocs_Parts&file=00001773.html <http://livedocs.adobe.com/flex/2/docs/wwhelp/wwhimpl/common/html/wwhelp .htm?context=LiveDocs_Parts&file=00001773.html> > > for how to validate multiple fields. I can it to work apart from the > setting of the actual errorString on the appropriate input box. > > I.E if I have three input boxes and box three has the error, then in the > example from livedocs it puts the error around whatever box I declared as > the listener. How do I put the error around the appropriate box? Any of > the 3 boxes could have an error. > > When debugging I can see that there is a property called actualListeners > which is an array, but its read only and the listener property only takes a > Object. I have a work around for this which passes in the form that I'm > validating to the custom validator then overriding the 'get > actualListeners()' function, but I'm sure that there must be a better way of > doing this. > > > > Thanks > > Kenneth. > >