Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

170
Vistas
jQuery composition event is undefined

I do not want users to enter numbers or special character within a name input field and I have achieved this with the following code:

jQuery(document).ready(function() {
   jQuery(".txtOnly").keypress(function(e) {
       var key = e.keyCode;
       if(key < 97 || key > 122) {
           e.preventDefault();
       }
   });
});

But I want to avoid numbers and special characters from microsoft IME Japanese Keyboard as well though the keypress does not work so I am using a jQuery composition event which is working but it always returns undefined, so I am unable to get the key code or the value this way.

My Code:

jQuery(document).ready(function() {
   jQuery(".txtOnly").on('compositionupdate', function(e) {
       var keyCode = e.keyCode;
       alert(keyCode); //Undefined 
       console.log(e.data); //Undefined 
   });
});

How I can get the keycode using a composition event or what other solution can I use for the Microsoft IME Japanese Keyboard?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda