Create preg_match for password validation allowing (!@#$%)

后端 未结 9 955
耶瑟儿~
耶瑟儿~ 2020-12-04 23:14

I would like to create a preg_match function to validate my passowrds, but I\'m not sure how to write it to allow the following special characters to be used: <

9条回答
  •  眼角桃花
    2020-12-04 23:32

    if (!preg_match('/^(?=.*\d)(?=.*[A-Za-z])(?=.*[!@#$%])[0-9A-Za-z!@#$%]
    {6,15}$/',($_POST['password']))) {
        $message='Password must contain 6 characters of letters, numbers and 
        at least one special character.';
    }
    

提交回复
热议问题