thanx...i gt it 4 the textInputs. i am stuck wit combo Boxes with same problem of tabbing n normal mouse events................can u help me plz?
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="validateText()"> <mx:Script> <![CDATA[ import mx.collections.ArrayCollection; import mx.events.ValidationResultEvent; import mx.events.ListEvent; import mx.controls.Alert; import mx.validators.NumberValidator; [Bindable]public var dataProvider1:ArrayCollection = new ArrayCollection(["Hello1","Hello2","Hello3"]); public var mandatoryTextValidator:NumberValidator; public function validateText():void{ mandatoryTextValidator = new NumberValidator(); mandatoryTextValidator.lowerThanMinError = "This field is required"; mandatoryTextValidator.minValue = 0; mandatoryTextValidator.required = true; mandatoryTextValidator.requiredFieldError = "This field is required"; mandatoryTextValidator.property = "selectedIndex"; } public function validateComboBox(event:Event):void { mandatoryTextValidator.source = event.currentTarget; mandatoryTextValidator.validate(); } ]]> </mx:Script> <mx:VBox width="452"> <mx:HBox> <mx:Label text="hii"/> <mx:ComboBox id="c1" width="100" focusOut ="validateComboBox (event);" change="validateComboBox(event);"/> </mx:HBox> <mx:HBox> <mx:Label text="hii"/> <mx:ComboBox id="c2" width="100" focusOut="validateComboBox (event);" change="validateComboBox(event);"/> </mx:HBox> </mx:VBox> </mx:Application> On Feb 25, 9:44 pm, GnanaPrakasam T <[email protected]> wrote: > Hi Sam, > > Define your validator initially and just assign the source component and > call validate . > this will work > > <?xml version="1.0" encoding="utf-8"?> > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" > *creationComplete="init()"* > layout="absolute"> > > <mx:Script> > <![CDATA[ > import mx.events.ValidationResultEvent; > import mx.events.ListEvent; > import mx.controls.Alert; > import mx.validators.NumberValidator; > > public var myValidator:NumberValidator; > > public function init():void{ > myValidator= new NumberValidator(); > // myValidator.source = event.currentTarget; > myValidator.required = true; > myValidator.allowNegative = false; > myValidator.property = "text"; > myValidator.requiredFieldError = "This field is required"; > myValidator.precision = 2; > myValidator.precisionError = "Invalid Precision"; > } > public function validateText(event:FocusEvent):void{ > myValidator.source = event.currentTarget; > * myValidator.validate();* > } > > *Gnanz.../http://gnanz-flexworld.blogspot.com* > > > > sam wrote: > > Hi > > > I am trying to set number validator for many textInputs present in one > > form. I am unable to do so. > > > My code is: > > > <?xml version="1.0" encoding="utf-8"?> > > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" > > layout="absolute"> > > > <mx:Script> > > <![CDATA[ > > import mx.events.ValidationResultEvent; > > import mx.events.ListEvent; > > import mx.controls.Alert; > > import mx.validators.NumberValidator; > > > public var myValidator:NumberValidator; > > > public function validateText(event:FocusEvent):void{ > > myValidator= new NumberValidator(); > > myValidator.source = event.currentTarget; > > myValidator.required = true; > > myValidator.allowNegative = false; > > myValidator.property = "text"; > > myValidator.requiredFieldError = "This field is > > required"; > > myValidator.precision = 2; > > myValidator.precisionError = "Invalid Precision"; > > > } > > > ]]> > > </mx:Script> > > > <mx:VBox width="452"> > > <mx:HBox> > > <mx:Label text="hii"/> > > <mx:TextInput id="a" width="100" focusOut="validateText(event);" > > restrict="012345678910 ."/> > > </mx:HBox> > > <mx:HBox> > > <mx:Label text="hii"/> > > <mx:TextInput id="b" width="100" > > focusOut="validateText(event);"/> > > </mx:HBox> > > <mx:HBox> > > <mx:Label text="hii"/> > > <mx:TextInput id="c" width="100" > > focusOut="validateText(event);"/> > > </mx:HBox> > > > </mx:VBox> > > </mx:Application> > > > Its not working on tabbing as well as on normal mouse action. > > > Please help me............sam- Hide quoted text - > > - Show quoted text - --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Flex India Community" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/flex_india?hl=en -~----------~----~----~----~------~----~------~--~---

