public static bool IsPasswordStrong(string password)
{
// Check for strong password
return Regex.IsMatch(password, @"^(?=.{8,})(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?!.*\s).*$");
}
protected void cmdSubmit_Click(object sender, EventArgs e)
{
string strtxtNewPwd = txtNewPwd.Text;
if (IsPasswordStrong(strtxtNewPwd) == false)
{
errorpanel.Style.Add(HtmlTextWriterStyle.Display, "inline");
status.Text = "Password must be atleast 8 characters long and should be a mix of atleast One Uppercase letter, One Lowercase letter and One Numeral.";
}
else
{
// Update password
}
}
Guidelines for creating strong password
Be at least eight characters long. Because of the way passwords are encrypted, the most secure passwords are 8 or 14 characters long.
Contain at least one character from the following three groups:
Group Examples
Uppercase Letters A,B,C...
Lowercase Letters a,b,c...
Numerals 0,1,2,3,4,5,6,7,8,9
Be significantly different from prior passwords.
Not contain your name or user name.
Not be a common word or name.
Exapmle:- Password1 => (P)Uppercase, (assword)Lowercase, (1)Numeral
{
// Check for strong password
return Regex.IsMatch(password, @"^(?=.{8,})(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?!.*\s).*$");
}
protected void cmdSubmit_Click(object sender, EventArgs e)
{
string strtxtNewPwd = txtNewPwd.Text;
if (IsPasswordStrong(strtxtNewPwd) == false)
{
errorpanel.Style.Add(HtmlTextWriterStyle.Display, "inline");
status.Text = "Password must be atleast 8 characters long and should be a mix of atleast One Uppercase letter, One Lowercase letter and One Numeral.";
}
else
{
// Update password
}
}
Guidelines for creating strong password
Be at least eight characters long. Because of the way passwords are encrypted, the most secure passwords are 8 or 14 characters long.
Contain at least one character from the following three groups:
Group Examples
Uppercase Letters A,B,C...
Lowercase Letters a,b,c...
Numerals 0,1,2,3,4,5,6,7,8,9
Be significantly different from prior passwords.
Not contain your name or user name.
Not be a common word or name.
Exapmle:- Password1 => (P)Uppercase, (assword)Lowercase, (1)Numeral