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