To get this work in Firefox.
<input id="Destination" value="" placeholder="Destination">
$('#Destination').on('keypress', function (e) { var regex = new RegExp("^[a-zA-Z0-9_ \b]+$"); var key = String.fromCharCode(!e.charCode ? e.which : e.charCode); var keystobepassedout="ArrowLeftArrowRightDeleteBackspaceTab"; if(keystobepassedout.indexOf(e.key)!=-1) { return true; } if (!regex.test(key)) { e.preventDefault(); return false; } });