By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,299 Members | 1,141 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,299 IT Pros & Developers. It's quick & easy.

Firefox and IE cursor key codes different?

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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.