Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML5 browser password validation (valid pattern attribute!): minimum 6 chars and at least 1 number and 1 Capital letter

Tags:

html

regex

I'm stuck with HTML5 embedded form validation (non javascript). I need to meet all this parameters:

  1. minimum 6 chars

  2. at least 1 number

  3. at least 1 Capital letter

Could you help me to make sure it works as pattern attribute? For example:

<input type="password" pattern="myPattern" /> Thanks.

like image 913
max Avatar asked Oct 23 '25 02:10

max


1 Answers

Thank you guys, I have found a working example and modified it:

<input type="password" pattern="^(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])(?=\S+$).{6,}$" />

edit: corrected typo

like image 103
max Avatar answered Oct 24 '25 16:10

max



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!