Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

168
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!