I want to add char code this to prevent in my JS form. This JS not working if I add this char code :
] \ /
—
jQuery.validator.addMethod("userNameRule", function(string, element) {
return !string.match(/[.;,`~!@#$%^&*()-+=|{[}'":?><]/g);
});
What I want to do now is, add that the char code into my JS.
So how can I do that?
your pattern contains some reserved characters like
. ^ $ ( ) { } - + ?In a character class you should only escape the
-anyway, because it is intended for range of symbols likea-zor0-9try to escape them like so
(or escape just the
-)