0
return: string 'invalid password, only letters and are accepted numbers' (length=55)
class Validapass
{
public function setValidapass($pass)
{
if (strlen($pass)<1)
return 'escreva a password';
else
if(!preg_match('/^[0-9a-z]$/i',$pass))
return 'password invalida, apenas letras e são numeros aceites';
else
return $pass;
}
}
Is the password you entered just a letter or a number? More than that it will be invalid as the regular expression is waiting for only one character.
– Woss
ja descobri! if(! preg_match('/ [0-9a-z]{4,20}$/i',$pass))
– edshewa
If the
_
is also allowed, it is much easier to do/^\w{4,20}$/
– Isac