Skip to content Skip to sidebar Skip to footer

Search Function With "enter" Key In Japanese

I am facing a problem with Japanese. I have a form that allows users can search the data. When users input the string to search and press 'Enter' key, the search function will exec

Solution 1:

This is because you're listening for an Enter key press (keyup). As you probably know, when typing Japanese in Hiragana mode, a list of possible kanji characters appears as you type. Enter is one of the keys used to confirm the kanji selection so most Japanese users will end up pressing Enter twice when they search for something. Your script executes on the first press so the second "submit" press is ignored.

A better alternative is to listen for a submit event instead of a keyup event. In jQuery you can use the .submit() method like this:

$("#formSearch").submit(function() {
  // Code to execute here
});

In your case, however, you don't seem to have any further script to execute, so maybe you don't need JavaScript at all. Try the form without JavaScript — if you can't submit it with Enter (in English or Japanese) there's probably a problem with your HTML so please update your question with your form's code.

Post a Comment for "Search Function With "enter" Key In Japanese"