Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

html password regular expression validation

Tags:

html

regex

I need to validate password with these requirements:-

  • At least 1 Uppercase
  • At least 1 Lowercase
  • At least 1 Number
  • At least 1 Symbol, symbol allowed --> !@#$%^&*_=+-
  • Min 8 chars and Max 12 chars

And got stucked a bit, here's what I have so far.

<form>
Password <input type="text" pattern="/^[a-zA-Z0-9!@#\$%\^\&*_=+-]{8,12}$/g" />
<input type="submit" value="Submit" />
</form>

JSFiddle

like image 655
Chan Chun Weng Avatar asked Jan 16 '15 02:01

Chan Chun Weng


1 Answers

try this pattern

^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#$%^&*_=+-]).{8,12}$

Demo

like image 111
alpha bravo Avatar answered Oct 05 '22 22:10

alpha bravo