I am using Teleriks RadInputManager control to check that a password is between 7 and 16 characters and contains at least 1 numeric and 1 special character, but when I type something that I know fits the expression, validation fails, so I believe my regular expression is wrong. Here is the expression I am using:
/^(?=.{7,16}$)\D+\d/
I tried the foll开发者_运维问答owing:
/^(?=.*\d)(?=.*[!@&.$#]).{7,16}$/
and tried to put the password test11. and it failed. I don't understand why because this is 7 characters and contains a numeric and a special character.
Use lookaheads:
/^(?=.*\d)(?=.*[-;:]).{7,16}$/
You didn't specify what a special character is so I just used an example, but you'll have to replace it with something better.
精彩评论