473,396 Members | 2,037 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

input (text) onkeypress with Japanese characters

I'm looking to perform input validation on an HTML input text element;
specifically, I'm looking to prevent anything other than numerical
characters from being entered.

I've got it working just fine for English characters by using an
'onkeypress' event handler, where basically all that is done is a
regular expression check of the character represented by
window.event.keyCode against a string containing "0123456789".

The problem I'm running into is when I switch from English to Katakana
characters - I can type in any character just fine, which is of course
wrong! The 'onkeypress' event doesn't get triggered whatsoever. I was
told by a coworker to handle the 'onpaste' event, but while that covers
yet another case for invalid input, the issue still persists: Katakana
characters of any kind can be typed into the text input without
triggering the 'onkeypress' or 'onpaste' events.

I'm using IE 5.5+ on Windows XP SP2 Japanese.

I hope someone has some experience with this. Thanks in advance for
any constructive feedback.

James

Sep 8 '05 #1
3 4672
Is there any other information I can provide that would help to receive
a response on this topic? It's quite confusing. ;)

James

Sep 9 '05 #2
Well, heck, james, i don't know much of anything about japanese
encoding, or more than being able to repeat the katakana that i learned
in my half year of japanese class, but i can try to give you some sort
of answer!

If you're validating with javascript, instead of limiting what the user
can & can't type in a particular box ((and i know it's slicker that
way, but)), perhaps you should wait until form submission time and
validate then, using the formelement.onsubmit event. Go through then
with your regex to see what kind of data is in there, and if the
javascript regex can correctly deal with katakana, that should be it!

Your coworker was right in that the onkeypress won't usually be
activated because when you type, the onkeypress works, but behind the
scenes, whatever the operating system is is gimmicking in the katakana:
you're entering it, it's figuring out what katakana you mean, and then
it's pasting it wherever is focused.

So, I'm not sure that you can get an "as you type" input for the
"strange" characters that are katakana and cryllic and whatnot, so
maybe the solution is not to try for that, but try for something you
can be sure of, like a form submission.

Hope that helps in some way,
-Brendan

Sep 9 '05 #3
Brendan,

First of all, thanks a lot for your response. It's good to see that
someone else sees it as I do... however, I don't have the option to
validate on submission of a form. The requirements dictate that it
pretty much has to be as close to 'onkeypress' as possible.

Now, you mention that in behind the scenes, the katakana characters are
being manipulated and then pasted in - there must be some way to catch
that. You'd think that 'onpaste' would be the ideal event, but as I've
already mentioned, that appears to be a bust.

I can't believe that there isn't a way to accomplish what I need to do
for all languages. Seems silly.

Thanks again, and if anyone has any further insight, please feel free
to share.

James

Sep 9 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: David Thomas | last post by:
Hi there, a while ago, I posted a question regarding reading japanese text from a text file. Well, since I solved the problem, I thought I'd post my solution for the benefit of other people with...
1
by: Robert Nurse | last post by:
Hi All, I've got a form which I'm trying to submit automatically when the user has entered 2 or more characters in a text imput box. Here's my set up: <SCRIPT language="JavaScript1.2">...
3
by: Ben | last post by:
Here's my form: <form name="aForm" method='post'> <input type=file name=file1 onkeypress='KeyPress()'><br> <a id='attachMoreLink' href='javascript:AddFileInput()">Attach More Files </a> <input...
2
by: Corepaul | last post by:
As input is typed into a text box, I would like to search a recordset for the first record that matches what has been typed so far. I would like to update the text box to display the letters typed...
11
by: jimstruckster | last post by:
I have a table with 10 rows, I want all rows except for the first to be hidden when the page first opens up. If the user puts a value in a text box in the first row then I want the second row to...
1
by: vega80 | last post by:
Hi. I have a problem with assigning an onkeypress-function to dynamically created input-boxes.I want to put the content of an input-field into a tag-list when the user hits enter. This works...
44
by: Kulgan | last post by:
Hi I am struggling to find definitive information on how IE 5.5, 6 and 7 handle character input (I am happy with the display of text). I have two main questions: 1. Does IE automaticall...
0
by: Anonieko | last post by:
Are there any javascript codes there? Answer: Yes On the PageLoad event call InitialClientControsl as follows /// <summary> /// This will add client-side event handlers for most of the...
3
by: kvnsmnsn | last post by:
I've written the following Javascript file that includes an input text field and an output text field, the latter of which is initialized to zero. Each time the user enters a number in the input...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.