我有一个用于注册过程的密码验证脚本,如果我没有设置最大长度限制,它可以正常工作。如果我添加最大限制为 32,它会忽略验证,创建帐户,即使我有超过 32 个字符。
工作脚本:
if (preg_match("/^.*(?=.{8,})(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z]).*$/", $_POST["password"]) === 0)
{
echo "The password must contain lower case characters, upper case characters and numbers. It's length should be between 8 and 32 characters.";
}
不工作的脚本:
if (preg_match("/^.*(?=.{8,32})(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z]).*$/", $_POST["password"]) === 0)
{
echo "The password must contain lower case characters, upper case characters and numbers. It's length should be between 8 and 32 characters.";
}
请在降级之前让我知道,以便我可以编辑我的问题。谢谢!