Requires Flex Regex Validation Expression for password, which only accepts alphanumeric values and requires one number
<mx:RegExpValidator id="regexValidator" source="{passwordInput}" property="text"
triggerEvent="" valid="onPasswordValidate(event)" invalid="onPasswordValidate(event)" />
private function validateRegister():void
{
regexValidator.expression = "^(?=.*(\d|\W)).{6,30}$";
regexValidator.validate();
}
a source to share
I'm not sure what would cause the validation error, but how far does your regex go to match alphanumeric strings with at least one try number ^(?=.*\d)\w{6,30}$
^ # Match begining of string
(?=.*\d) # Lookahead, assert there is any number of characters followed by a digit
\w{6,30} # \w matches letters, digits and the underscore character, 6-30 of them
$ # Match End of string
If you only want to use letters and numbers, \w
you can use instead [0-9a-zA-Z]
.
Your current regex ^(?=.*(\d|\W)).{6,30}$
matches any string that contains at least one character other than [a-zA-Z_]
( \d|\W
matches a character or a no-word character) between 6 and 30 characters in length, which doesn't necessarily match the requirements you specify.
a source to share
According to the ActionScript manual, the backslash is a reserved character. Therefore your expression should look like
"^(?=.*(\\d|\\W)).{6,30}$"
a source to share