i need a regex for password validation. password should contain
atleast 1 capital
atleast 1 small
atleast 1 specialchar
atleast 1 number
i'm trying with following ....
$regex="/[A-Z]/"; //regular expression
if (!preg_match($regex,$sPassword))
{
$this->printDebug(cSYS_LOG_LEVEL_ERROR, "Login failed.Invalid password ");
return false;
}
$regex="/[a-z]/";
if (!preg_match($regex,$sPassword))
{
$this->printDebug(cSYS_LOG_LEVEL_ERROR, "Login failed.Invalid password ");
return false;
}
$regex="/[0-9]/";
if (!preg_match($regex,$sPassword))
{
$this->printDebug(cSYS_LOG_LEVEL_ERROR, "Login failed.Invalid password ");
return false;
}
$regex="/[\W_]/"; //special characters and underscore character
if (!preg_match($regex,$sPassword))
{
$this->printDebug(cSYS_LOG_LEVEL_ERROR, "Login failed.Invalid password ");
return false;
}
but i need a single line like following
$regex="/^([A-Z]){1,}+([a-z]){1,}+([0-9]{1,}+([\W_]){1,}+$/";
if (!preg_match($regex,$sPassword))
{
print "invalid Password"."<br>";
}
but it's not working
urgent...
any help pls...
This post has been edited by kummu4help: 16 August 2008 - 05:26 AM

New Topic/Question
Reply




MultiQuote







|