left & right arrow ASCII char recognition, in ff

N

neoswf

hi all
i have this function:
--
function userNameValidChars(e) {
if (!e) var e = window.event;
if (e.keyCode) key = e.keyCode;
else if (e.which) key = e.which;
if(!(key==37) && !(key==39))
return false;
return true;
}
<input type="text" onkeypress="return userNameValidChars(event)" />
--
I'm trying to block chars that been typed into this input element. but
i have this problem:
FF force u to define which CHARS are going to be typed inside this
input element.
IE doesn't force u. ffff does.
so i defined Backspace, Horizontal tab and left & right arrows
those two links r keyCode 37 & 39 (according to FF).
but those two r also ' & %.

my question is: what is the ASCII code for left and right arrows?
how can i allow FF to use left&right arrows in inputs i use this code
on?

Thanks a lot, NeoSwf

http://www.bbsinc.com/iso8859.html
 
M

Martin Honnen

neoswf wrote:

how can i allow FF to use left&right arrows in inputs i use this code
on?

For Mozilla/Firefox the solution is to distinguish between the event
properties keyCode (for the arrow keys) and charCode (for characters
which have an Unicode codepoint), example is here:
<http://home.arcor.de/martin.honnen/javascript/2006/08/test2006081501.html>
The which property is is for backwards compatibility with Netscape 4, I
would not use it for Mozilla/Firefox where keyCode and charCode allow
finer control.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top