Closed Bug 225443 Opened 22 years ago Closed 22 years ago

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

Categories

(Core :: DOM: Events, defect)

PowerPC
macOS
defect
Not set
major

Tracking

()

RESOLVED INVALID

People

(Reporter: x-cash, Unassigned)

Details

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.
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.
Resolving this bug to invalid, see Comment #2. Also see Bug 228850 for example.
Status: UNCONFIRMED → RESOLVED
Closed: 22 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.