Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

HTML Input Pattern claims mismatch while JavaScript test claims match

I am attempting to do a pattern match on a password input and for some reason HTML claims there is a mismatch while JavaScript claims it matches. Testing my RegExp on regexr.com/7gmmi claims it is a-okay…

Regexp: /^(?!.(.)\1{1})(?=(.[\d]){2,})(?=(.[a-z]){2,})(?=(.[A-Z]){2,})(?=(.*[\D\W\S]){2,})(?:[\d\w\S]){8,64}$/

What am I missing?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

<input id="password" type="password" placeholder="Password Input" pattern="/^(?!.*(.)\1{1})(?=(.*[\d]){2,})(?=(.*[a-z]){2,})(?=(.*[A-Z]){2,})(?=(.*[\D\W\S]){2,})(?:[\d\w\S]){8,64}$/">
const patternPass = new RegExp(/^(?!.*(.)\1{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

>Solution :

Have you tried removing those slashes at the beginning and end of the pattern attribute and testing again?

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading