¿Cómo bloquear una "Coma" en la entrada HTML con el navegador Firefox?
Este código Javascript funciona para Opera Browser:
// ----- Block the "COMMA" for all inputs. $(document).keydown(function(e) { var keyCode = e.keyCode || e.which; if(keyCode==188){ // alert("COMMA has been pressed on the keyboard...") ; e.preventDefault(); // Note, "preventDefault" has to be within "if". } });Esto es lo que funcionó para Firefox y otros 2 navegadores:
// ----- Block the "COMMA" for all inputs. document.addEventListener('keydown', function(e) { if (e.key === ',') { e.preventDefault(); return false; } })Gracias
keyCode ha quedado obsoleto . Utilice e.key en su lugar.
document.addEventListener('keydown', e => { if (e.key === ',') { e.preventDefault(); return false; } })