HEXAQ : A friendly question - answer site for IT professionals

How to prevent to have three sequential characters as password?


0

I want to prevent uses from entering any three consequent characters from alphabet or numbers. I tried adding switch case statement but that become very lengthy to manage.

I searched in RegExLib but couldn't succeed.

Users will not be allowed to have three sequential characters. Example:

Password shouldn't be abc, bcd, cde, def, efg, 123, 234, 890 and others in same way.

Is there any way that make my password strong?

Â
asked
 


≡ Total 1 Answer

0

In your password validation method you can use a Regular expression this way

...
...
string invalidPasswordString = "^(.) (abc|bcd|cde|def|efg|hij|ijk|jkl|klm|kmn|mno|nop|opq|pqr|qrs|rst|stu|tuv|uvw|vwx|wxy|xyz|012|123|234|345|456|567|678|789|890)(.)$";
var validationRegex = new Regex(invalidPasswordString);
if (validationRegex.IsMatch(passwordTextbox.Text))
{
valid = false;
}
else
{
...
}
...
...

Â
replied


Enter your reply here
Answer Preview: