password validator using RegExp in Flex
Posted
by kalyaniRavi
on Stack Overflow
See other posts from Stack Overflow
or by kalyaniRavi
Published on 2010-05-20T11:41:15Z
Indexed on
2010/05/20
11:50 UTC
Read the original article
Hit count: 329
flex
|flexbuilder
I have seen several examples in Flex for passowrd validator using RegExp. But every where the validation is happend for single validation.
I have a requirement, like password validations like
• At least one Upper case letter
• At least one numeric character
• At least one special character such as @, #, $, etc.
• At least one Lower case letter
• password lenght minimum 6 digits
• password cannot be same as user name
Can anyone provide me a code for this..? I have the code only for checking the password is valid or not . check the below code.
MXML CODE
<mx:FormItem label="Username:" x="83" y="96" width="66">
</mx:FormItem>
<mx:FormItem label="Password:" x="88" y="123" width="61">
</mx:FormItem>
<mx:Button label="Login" id="btnLogin" tabIndex="2" click="login();" enabled="{formIsValid}" x="327" y="162" width="84"/>
<mx:TextInput id="txtPassword" displayAsPassword="true" change="validateForm(event);" x="152" y="121" width="217"/>
<mx:TextInput id="txtUserId" change="validateForm(event);" x="152" y="94" width="217"/>
AS Code:
private function validateForm(event:Event):void
{
focussedFormControl = event.target as DisplayObject;
formIsValid = true;
formIsEmpty = (txtUserId.text == "" && txtPassword.text == "");
validate(strVUserId);
validate(strVPassword);
}
private function validate(validator:Validator):Boolean
{
var validatorSource:DisplayObject = validator.source as DisplayObject;
var suppressEvents:Boolean = (validatorSource != focussedFormControl);
var event:ValidationResultEvent = validator.validate(null, suppressEvents);
var currentControlIsValid:Boolean = (event.type == ValidationResultEvent.VALID);
formIsValid = formIsValid && currentControlIsValid;
return currentControlIsValid;
}
© Stack Overflow or respective owner