I'm trying to use a regex expression in AS3/Flex4.6 to check for passwords meeting the following criteria:
- Between 6 and 15 characters
- Must contain at least one lower case letter
- Must contain at least one upper case letter
- Must contain at least one number (e.g 0-9)
So far, here is what I'm using:
<mx:RegExpValidator source="{loginPwd}" property="text"
expression="^\w*(?=\w*\d)(?=\w*[a-z])(?=\w*[A-Z])\w*$"
valid="rh(event);" invalid="rh(event);"/>
It does everything except catch password length of 6 to 15 characters. I could use a StringValidator
to do this, but I'd rather have the RegExpValidator
do both (so that I don't have the situation where multiple error messages are displayed for one TextInput field, e.g. one for each validator).
I've tried the following regex expressions, but while they compile, they do not work (for example, aaAA33
doesn't pass).
expression="((?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{6,15})"
expression="(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{6,15}"
expression="(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{6,15}^$"
expression="^.*(?=.{6,15})(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).*$"
No comments:
Post a Comment