I implemented a regular expression validator in an aspx form using the pattern
((?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*\W).{6,15})
, and it worked perfectly.
However, when I attempted to use the same expression in JavaScript, it failed. Why is that?
Here's the code snippet in JavaScript:
var regularExpression = ((?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*\W).{6,15})
if (regularExpression.test(newPassword)) {
alert("Password must be at least 6 characters but not more than 15 characters, and should include at least one uppercase letter, one lowercase letter, one special character, and one numeric digit.");
return false;
}