Must contain at least one number and one uppercase and lowercase letter and one special charectar, and at least 8 or more characters.
Method First:
<form action="#">
Password: <input type="password" name="password" id="password"
pattern="(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[^\w\s]).{8,}"
title="Must contain at least one number and one uppercase and lowercase letter and one special charectar, and at least 8 or more characters">
<input type="submit">
</form>
Method second through PHP validation :
$uppercase = preg_match('@[A-Z]@', $password); //uppercase
$lowercase = preg_match('@[a-z]@', $password); //lowercase
$number = preg_match('@[0-9]@', $password); //numbers
$special = preg_match('@[!@#$%^&*/()\-_=+{};:,<.>]@', $password); //special charectar
if(!$uppercase || !$lowercase || !$number || !$special || strlen($password) < 8) {
// tell the user something went wrong
}
5 years ago
Very helpfull