I have a quick question about the regular expression for symbols like !@#$%^&*()_+
in JavaScript. So, I am trying to implement it for the password validation, and I followed some documentation about regular expressions I found online, but it did not work correctly only for symbols (it worked for numbers and alphabet characters)
The function below is the sample code of what I used on my web application.
When I type a password on the web application, this function always returns false even if I put in symbols.
function valid_password(password) {
var sym = new RegExp('[ @#$%^&_*-+=[]{}()?]+');
if (sym.test(password)) {
return true;
} else {
return false;
}
}