Groups
Sign in
Groups
macromedia.flex.general_discussion
Conversations
About
Send feedback
Help
info
Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss
Learn more
Using Validator and Setting Focus
1 view
Skip to first unread message
Eduardo SIlveira
unread,
May 2, 2013, 9:44:04 AM
5/2/13
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to
I'm get today the way to setFocus() on the event target by Validator.
To use on Flex 3.0+ the validators you can try it.
<fx:Declarations>
<fx:Array id="arrValidadores">
<s:NumberValidator property="selectedIndex" minValue="0" source="{dplCadType}" required="true" triggerEvent="change"/>
<mx:StringValidator property="text" source="{txtName}" required="true" triggerEvent="change"/>
<mx:EmailValidator property="text" source="{txtEmail}" invalidCharError="Invalid Character!" invalidDomainError="Invalid Domain" missingAtSignError="Invalid Email"
</fx:Array>
</fx:Declarations>
<fx:Script>
<![CDATA[
import mx.validators.Validator;
protected function validateFields():void{
var arrError:Array = Validator.validateAll(arrValidadores);
if(arrErros.length > 0) {
arrErros[0].target.source.setFocus();
Alert.Show("Check the red field!");
}
]]>
</fx:Script>
Set the fields and use that function you will return the alert and set focus at the target was not validated.
0 new messages