469,272 Members | 1,473 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,272 developers. It's quick & easy.

Firefox and IE cursor key codes different?

Hi

I'm pretty new to javascript and cross-browser stuff.

I want to restrict text input boxes to only numbers and decimal points
and exclude all else....except cursor keys, home keys etc.

I've managed to do this by handling the keyCode in the keypress event,
but the same code on IE allows cursor keys to be used, but firefox
doesn't.

Is there a difference in how I should handle both browsers?

Regards,
Mark

Nov 15 '06 #1
2 2067
Lee
mm*******@yahoo.co.uk said:
>
Hi

I'm pretty new to javascript and cross-browser stuff.

I want to restrict text input boxes to only numbers and decimal points
and exclude all else....except cursor keys, home keys etc.
Bad idea. As you've found, you can't be sure you've handled all
browsers correctly. You're likely to frustrate your users and
you gain nothing by it. Use an onChange event to audit the value
entered by the user to make sure it only contains valid characters.

Consider the person who sometimes hits the wrong key while typing,
but realizes it and hits the backspace, then the correct key, and
then continues typing (as I've managed to do three times in this
sentence). If you had blocked that incorrect key, their backspace
would have deleted the previous, correct, character, instead, and
they might not notice that. Input filtering causes input errors.

Or did you forget to allow backspace?
--

Nov 15 '06 #2
I appreciate what you're saying, but I really do want to restrict the
input text control to numerics.

Backspace seems to work, it's just cursor keys.

Regards,
Mark

Nov 15 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by niconedz | last post: by
10 posts views Thread by Eric-Sebastien Lachance | last post: by
5 posts views Thread by Martin Chen | last post: by
4 posts views Thread by the other john | last post: by
3 posts views Thread by atn2002 | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.