开发者

Password Regular Expression is not working with RadInputManager?

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜