This is the simply way that I do it...I think I picked this up from
another example on the interweb...:)
private function validatePass():void {
if (password.text != password_confirmation.text) {
password.errorString = "Password and Password
Confirmation must match!";
password_confirmation.errorString = "Password and
Password Confirmation must match!";
validPass = false;
} else {
password.errorString = null;
password_confirmation.errorString = null;
validPass = true;
}
}
<mx:FormItem label="Password">
<mx:TextInput id="password" displayAsPassword="true"
width="150"/>
</mx:FormItem>
<mx:FormItem label="Confirm">
<mx:TextInput id="password_confirmation"
displayAsPassword="true" width="150" change="validatePass()"/>
</mx:FormItem>
--- In [email protected], "flexawesome" <[EMAIL PROTECTED]> wrote:
>
> Hi :))
>
> I have done some coding below for user register form....
>
> I would like to verfiy email, passowrd and confirm password fiels
> before clicking the submit button, if password doesn't match then
> point the error message right of confirm password.
>
> Have you done this before? I am new to Flex and appreciate if there
> is some code or toutorials, that would be great.
>
> Cheers & THANKS
>
>
>
> ================================ CODE ===============================
> <?xml version="1.0" encoding="utf-8"?>
> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
> <mx:Script>
> <![CDATA[
> import mx.managers.ToolTipManager;
> import mx.core.IToolTip;
> import mx.controls.ToolTip;
>
> import mx.core.IFlexDisplayObject;
> import mx.core.UIComponent;
>
> import flash.events.MouseEvent;
>
> import com.*
>
> public var myTip:ToolTip;
>
>
> import mx.controls.Alert;
>
> private function verifyPassword
> (event:MouseEvent):void {
> if (passwordInput.text !=
> confirmPasswordInput.text) {
> /*
> //var target:UIComponent =
> UIComponent(event.currentTarget);
> var erroMsg:String = "PLEASE
> CORRECT YOUR PASSWORD."
> myTip = ToolTip
> (ToolTipManager.createToolTip(erroMsg, cp.x, cp.y,"errorTipRight"));
>
>
> var pt:Point = new Point
> (event.localX, event.localY);
> pt = event.target.localToGlobal(pt);
> pt = panelHolder.globalToContent(pt);
>
>
> Alert.show("You clicked on the " +
> pt.x);
> */
>
> }
>
> /*
> var target:UIComponent =
> UIComponent(event.currentTarget);
>
> var erroMsg:String = "PLEASE CORRECT YOUR
> PASSWORD."
> myTip = ToolTip
> (ToolTipManager.createToolTip(erroMsg, 700, 200,"errorTipAbove"));
> myTip.setStyle("color",0xff0000);
> myTip.setStyle("cornerRadius",10);
> myTip.setStyle("borderColor",0x000000);
> myTip.setStyle("fontSize",9);
> */
>
>
> //private function destroyErrorMsg():void {
> // ToolTipManager.destroyToolTip(myTip);
> //}
> }
> ]]>
> </mx:Script>
>
>
> <mx:Style>
> ToolTip {
> borderSkin: ClassReference
> ("com.errorToolTip");
> }
> </mx:Style>
>
> <mx:EmailValidator id="nemailameValidator" property="text"
> source="{emailInput}"/>
>
> <mx:StringValidator id="passwordValidator" property="text"
> source="{passwordInput}" minLength="8"/>
>
> <mx:StringValidator id="confirmPasswordValidator" property="text"
> source="{confirmPasswordInput}" minLength="8"/>
>
> <mx:Panel id="panelHolder" title="User Register">
> <mx:Form>
> <mx:FormItem label="Email:">
> <mx:TextInput
> id="emailInput" focusOut="emailInput.dispatchEvent
> (new MouseEvent('mouseOver'))"/>
> </mx:FormItem>
> <mx:FormItem label="Password:">
> <mx:TextInput
> id="passwordInput"
> focusOut="passwordInput.dispatchEvent(new MouseEvent('mouseOver'))"/>
> </mx:FormItem>
> <mx:FormItem id="cp" label="Confirm Password:">
> <mx:TextInput
> id="confirmPasswordInput"
> focusOut="confirmPasswordInput.dispatchEvent(new MouseEvent
> ('mouseOver'))"/>
> </mx:FormItem>
> </mx:Form>
> <mx:HBox>
> <mx:Button label="Submit"
> click="verifyPassword(event)"/>
> </mx:HBox>
> </mx:Panel>
> </mx:Application>
>
>
> =====================================================================
>