HTML input mode claims inconsistent while JavaScript test claims consistent
P粉208469050
P粉208469050 2024-04-02 08:50:49
0
1
294

I'm trying to do a pattern match on the password input, but somehow the HTML claims there is a mismatch, while the JavaScript claims a match. Testing my regex at regexr.com/7gmmi shows everything works fine...

What did I miss?

<input id="password" type="password" placeholder="密码输入" pattern="/^(?!.*(.){1})(?=(.*[\d]){2,})(?=(.*[a-z]){2,})(?=(.*[A-Z]){2,})(?=(.*[\D\W\S]){2,})(?:[\d\w\S]){8,64}$/">
const patternPass = new RegExp(/^(?!.*(.){1})(?=(.*[\d]){2,})(?=(.*[a-z]){2,})(?=(.*[A-Z]){2,})(?=(.*[\D\W\S]){2,})(?:[\d\w\S]){8,64}$/);

console.log(patternPass.test("FAGX@s#A2dred01sd"));

/// true

P粉208469050
P粉208469050

reply all(1)
P粉903969231

Have you tried removing the leading and trailing slashes from the pattern attribute and retesting?

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!