$('input').on('keypress', function (event) {
var regex = new RegExp("[ -~]");
var key = String.fromCharCode(!event.charCode ? event.which : event.charCode);
if (!regex.test(key)) {
event.preventDefault();
return false;
}
});

You may also like

Leave a Reply