Scott, I put the valid and invalid Events onto the NumberValidator, and they were triggered when I expected, but this still doesn't fullfill my needs.
My example was just to illustrate a point, I am not actually displaying any error messages. My application uses 3 fields, cost price, margin and tax rate to calculate the selling price. What I want to achieve is that when all 3 fields are valid the selling price is calculated and displayed, then if a single field is changed the price is re-calculated. In my code to do the calculations, I check the error string of the 3 textInput fields to see if they are "", and only then do I calculate the price, if any field is in error then the selling price cannot be calculated and displayed. Using the events on the NumericValidator works if there is no error, but when there is an error the error string is not empty and the invalid event is triggered. The problem is that when a correct value is then entered the valid event is fired, but the error string still has the old error, so my calculation routine still thinks that a field has an error. Andrew --- In [email protected], Scott Melby <[EMAIL PROTECTED]> wrote: > > I believe what you want to do is use the trigger and triggerEvent > properties of your NumberValidator, then use the NumberValidators valid > and invalid events to do the work. To try this remove the event > handling from your existing code and try the following > > <mx:NumberValidator source="{testTXT}" property="text" minValue="1" > maxValue="99" trigger="{testTxt}" triggerEvent="change" valid="testA()" > invalid="testB()"/> > > Also worth noting is that Flex has a really great built-in ability to > show the error information with the invalid field. To check this out try > > public function testA():void{ > testTxt.errorString = ""; > } > > public function testB():void{ > testTxt.errorString = "The number must be between 1 and 99"; > } > > hth > Scott > > Scott Melby > Founder, Fast Lane Software LLC > http://www.fastlanesw.com > > > > greenfishinwater wrote: > > > > I have a form with a few TextInput components. I have a TextInput with > > a NumberValidator as one of the form items. On this TextInput I have > > coded the valid and invalid events to populate other fields depending > > on what has been entered. My experience is that the valid event is not > > working correctly. > > > > I have this sample code to illustrate: > > > > in the first field enter 10, the valid event does not fire > > in the first field enter 200, the invalid event fires correctly. > > in the first field enter 10, the valid event does work now > > in the first field enter 20, the valid event does not fire. > > > > Any ideas. What I want is a way to fire an event after the validator > > has completed, the valueCommit and FocusOut seem to fire before the > > validator has completed. > > > > <?xml version="1.0" encoding="utf-8"?> > > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml > > <http://www.adobe.com/2006/mxml>" > > layout="absolute"> > > <mx:Script><![CDATA[ > > private function testA():void { > > msgTXT.text = "Valid: " + testTXT.text; > > } > > private function testB():void { > > msgTXT.text = "Invalid: " + testTXT.text; > > } > > ]]></mx:Script> > > <mx:NumberValidator source="{testTXT}" property="text" minValue="1" > > maxValue="99"/> > > <mx:VBox> > > <mx:Form> > > <mx:FormItem label="Integer"> > > <mx:TextInput id="testTXT" valid="testA()" invalid="testB()"/> > > </mx:FormItem> > > <mx:FormItem label="Message"> > > <mx:TextInput id="msgTXT" editable="false" width="160"/> > > </mx:FormItem> > > </mx:Form> > > </mx:VBox> > > </mx:Application> > > > > Thanks > > > > Andrew > > > > >

