**question:**
Javascript regular expression password validation having special characters
url:http://stackoverflow.com/questions/12090077/javascript-regular-expression-password-validation-having-special-characters
```
var reg = /^(?=.*[0-9])(?=.*[!@#$%^&*])[a-zA-Z0-9!@#$%^&*]{6,16}$/;
```
> 说明
必须拥有数字和特殊字符,并且在6~16位之间
Without it, your current regex only matches that you have 6 to 16 valid characters, it doesn't validate that it has at least a number, and at least a special character. That's what the lookahead above is for.
`(?=.*[0-9])` - Assert a string has at least one number;
`(?=.*[!@#$%^&*])` - Assert a string has at least one special character.
> 学习
密码需求:必须满足大写字母,数字,特殊字符中两个条件。长度8~16