Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

169
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda