I have used regular expression validator in aspx form.I have used this express ((?=.*\\d)(?=.*[az])(?=.*[AZ])(?=.*\\W).{6,15})
,working fine.
I am trying to use same expression in javascript,but that fail why so ?
In javascript
var regularExpression = ((?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*\W).{6,15})
if (regularExpression.test(newPassword)) {
alert("Password must be at least 6 characters, not more than 15 characters, and must include at least one upper case letter, one lower case letter, one special character and one numeric digit.");
return false;
}
you should use /
instead of (
for RegExp
var regularExpression = /(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*\W).{6,15}/;
if (regularExpression.test(newPassword)) {
alert("Password must be at least 6 characters, not more than 15 characters, and must include at least one upper case letter, one lower case letter, one special character and one numeric digit.");
return false;
}
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.