I'm looking to add a (.
) to the allowed characters in my function below:
$(id).bind('keypress', function(event) {
var regex = new RegExp("[()a-zA-Z0-9 ?,/-]");
var key = String.fromCharCode(!event.charCode ? event.which : event.charCode);
if (!regex.test(key)) {
event.preventDefault();
return false;
}
});
However, every time I add it it comes up with the error:
Uncaught SyntaxError: Invalid regular expression: /[()a-zA-Z0-9 ?,/-.]/: Range out of order in character class
I've tried adding just (.
) & also tried adding it with (\.
) but still the same error.
Please can you assist to where I need to add this (.
) ?