Not sure how to do that.  If the validators are created dynamically:
var c:UIComponent = formItem[0];
c.addEventListener(FocusEvent.FOCUS_OUT,UpdateItem);
var validateString:StringValidator = new
StringValidator();
validateString.source = c;
validateString.property = "text";
validateString.required = formItem[0].parent.required;
validateString.maxLength = formItem[0].maxChars - 10;

How do I make an an associative array?  Not sure what the id of the
validator is.

Thanks for the help,
timgerr

FYI, c is a UIComponent

--- In [email protected], "Tracy Spratt" <[EMAIL PROTECTED]> wrote:
>
> Perhaps create an associative array of references to the validators?
> 
> Tracy
> 
>  
> 
> ________________________________
> 
> From: [email protected] [mailto:[EMAIL PROTECTED] On
> Behalf Of timgerr
> Sent: Wednesday, November 05, 2008 7:12 PM
> To: [email protected]
> Subject: [flexcoders] Get id of dynamic validator
> 
>  
> 
> Hello, I have this form and I am createin dynamic validators for each
> textinput. I cannot see how to get the validators id when I try and
> validate the textinput boxes, here is my code:
> <mx:Form width="370" id="userInfoForm">
> <mx:FormItem label="First Name" required="true"
> id="fname_25_string">
> <mx:TextInput id="firstName" toolTip="First Name: Max Length 25
> Characters"
> maxChars="35" text="James"/>
> </mx:FormItem>
> <mx:FormItem label="Last Name" required="true" id="lname_25_string">
> <mx:TextInput id="lastName" toolTip="Last Name: Max Length 25
> Characters"
> maxChars="35"/>
> </mx:FormItem>
> <mx:FormItem label="Email" required="true" id="Email__">
> <mx:TextInput id="email" editable="false" toolTip="Cannot edit
> this field"/>
> </mx:FormItem>
> <mx:FormItem label="Title" id="tit_25_string">
> <mx:TextInput id="title" maxChars="35" toolTip="Title: Max
> Length 25 Characters"/>
> </mx:FormItem>
> </mx:Form>
> 
> So I do a creationcomplete to run a function to get a list of all the
> textboxes:
> private function GetChild(item:Object):void
> {
> var formItems:Array = item.getChildren();
> // loop items and add values
> for (var i:int = 0; i < formItems.length; i++)
> {
> // formItem
> var formItem:Array = formItems[i].getChildren();
> var c:UIComponent = formItem[0];
> if(c.className.toString() == 'TextInput'){
> var rtnID:String = c.id;
> formItem[0].text = _performaReturnUsersData[rtnID];
> /* adding an eventlistener (focuseEvent) to all textinput
> */
> c.addEventListener(FocusEvent.FOCUS_OUT,UpdateItem);
> var validateString:StringValidator = new
> StringValidator();
> validateString.source = c;
> validateString.property = "text";
> validateString.required = formItem[0].parent.required;
> validateString.maxLength = formItem[0].maxChars - 10;
> }
> }
> }
> 
> This function will go through an find textinput boxes then assign a
> validator to them. So all is working but the problem is I have no
> idea how to validate the data without knowing the id of the individual
> instance of the validator.
> 
> I have added a listener to the instances of the textinput called
> UpdateItem, so here is the code:
> 
> function UpdateItem(f:FocuseOut):void
> {
> trace(f.target.id);
> // Not sure what to do here becuase I dont know the id of the
> validator attached to the textinput
> }
> 
> How can I see if the textinput passes the validators?
> 
> Thanks for the help,
> timgerr
>


Reply via email to