when returning false from onkeypress, onkeydown, onkeyup event handler the keycode is inserted in input field as returning true

RESOLVED INVALID

Status

()

Core
DOM: Events
--
major
RESOLVED INVALID
14 years ago
14 years ago

People

(Reporter: Paolo Casciello, Unassigned)

Tracking

Trunk
PowerPC
Mac OS X
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

14 years ago
User-Agent:       Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.6a) Gecko/20031029
Build Identifier: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.6a) Gecko/20031029

Suppose to have a <input ... onkeypressed="handler()"> statment with func
returning false.

When func() ends to modify the input field (simple case, if a number is != 0 i
make the field empty) the default event handler is executed and the field has
the value of the key pressed.
JavaScript 1.2 specifications says that if i return false in the event handler
the keystroke is lost.


Reproducible: Always

Steps to Reproduce:
1.create an input field as the details example.
2.press a key in the input field

Actual Results:  
The number apppears instead of being rejected.

Expected Results:  
The number must be rejected because i return false in the handler.

There's no easy workaround. A programmer must use later controls to empty the
input field.

Comment 1

14 years ago
you aren't returning false to the handler, try this to check the difference:
onkeypress="return false", and so the the code becomes: onkeypressed="return
handler()"

This is a WFM, please mark it as such if the correct code fixes your problem or
attach a minimal testcase showing the problem.

Comment 2

14 years ago
Resolving this bug to invalid, see Comment #2. Also see Bug 228850 for example.
Status: UNCONFIRMED → RESOLVED
Last Resolved: 14 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.