Atleast 1-lower,1-upper,1-numeric,1-special character
public static string checkpasswordCharacters(string password)
{
string msg = "";
Regex len = new Regex("^.{6,15}$");
Regex num = new Regex("\\d");
// Regex alphaL = new Regex("\\D");
Regex alphaL = new Regex("[a-z]");
Regex alphaU = new Regex("[A-Z]");
Regex special = new Regex("[><#@=._!$-]");
if (!len.IsMatch(password) )
{
msg += "-Minimum password length is 6 characters \\n";
}
if (!num.IsMatch(password))
{
msg += "-Please enter atleast one numeric value \\n";
}
if (!alphaL.IsMatch(password))
{
msg += "-Please enter atleast one lower case alphabet \\n";
}
if (!alphaU.IsMatch(password))
{
msg += "-Please enter atleast one upper case alphabet \\n";
}
if (!special.IsMatch(password))
{
msg += "-Please enter atleast one special Character \\n";
}
return msg;
}
public static string checkpasswordCharacters(string password)
{
string msg = "";
Regex len = new Regex("^.{6,15}$");
Regex num = new Regex("\\d");
// Regex alphaL = new Regex("\\D");
Regex alphaL = new Regex("[a-z]");
Regex alphaU = new Regex("[A-Z]");
Regex special = new Regex("[><#@=._!$-]");
if (!len.IsMatch(password) )
{
msg += "-Minimum password length is 6 characters \\n";
}
if (!num.IsMatch(password))
{
msg += "-Please enter atleast one numeric value \\n";
}
if (!alphaL.IsMatch(password))
{
msg += "-Please enter atleast one lower case alphabet \\n";
}
if (!alphaU.IsMatch(password))
{
msg += "-Please enter atleast one upper case alphabet \\n";
}
if (!special.IsMatch(password))
{
msg += "-Please enter atleast one special Character \\n";
}
return msg;
}
No comments:
Post a Comment