简体   繁体   中英

html password regular expression validation

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

try this pattern

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

Demo

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM