[thelist] Why does this JS code work the way it does???

Lee kowalkowski lee.kowalkowski at googlemail.com
Tue Dec 12 07:31:02 CST 2006

On 11/12/06, Anthony Baratta <anthony at baratta.com> wrote:
> Normally I can tear into a piece of code and figure out what it's doing. But I can't quite see why this JS function is working exactly the way it does. Here's the function, my comments follow:
> <input type="text" class="frmInputText2" style="width: 55px"
>   id="FooElement"
>   onkeypress="return CheckNumericKeyStroke();">
> Now, here's what I don't understand - why do the backspace and delete keys work in the above text input element? They should comeback with "false" and not "fire". But they do. Why? IE quirk?

The browser will receive and act upon the onkeydown events for
Backspace, Enter, F5, etc..., you're waiting for the onkeypress event,
too late I'm afraid.  Change it to onkeydown.


More information about the thelist mailing list