Regular Expression for password validation
The following regular expression is for a 4 to 8 char password and containing at least an alphabet and one Number. You can change numbers in the end to your allowed password length.
private bool IsValidPassword(string strPassword)
{
Regex compareRegex = new Regex(@"(?!^[0-9]*$)(?!^[a-zA-Z]*$)^([a-zA-Z0-9]{6,15})$");
if (compareRegex.IsMatch(strPassword))
{
return true;
}
else
{
return false;
}
}
try this link:
http://www.manindra.net/post/2010/04/09/AspNet-Regular-Expressions.aspx