javascript keypress function: case-insensitive a-z, numbers and a few special chars?
- by user239831
hey guys,
$('.s').keyup(function(e) {
if (!/[A-Za-z0-9]/.test(String.fromCharCode(e.which))) {
return false;
}
I wonder what is the best regex solution for my application.
I have an ajax-based search that should just trigger the search when actual characters are pressed like a-Z (upper and lowercase), numbers and maybe a questionmark, a dash(hyphen), and an exclamation mark. Also the spacebar should be enabled.
Otherwise the ajax search would be triggered as well if the shift-, option, or control-key, is pressed.
What's the easiest regex pattern to understand here?
thank you for your help