[DOM] onkeydown="return false" doesn't cancel the key in INPUT TYPE="text"

VERIFIED DUPLICATE of bug 1572

Status

()

Core
Event Handling
P2
normal
VERIFIED DUPLICATE of bug 1572
18 years ago
17 years ago

People

(Reporter: Martin Honnen, Assigned: joki (gone))

Tracking

({testcase})

Trunk
Future
x86
Windows 98
testcase
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

18 years ago
NN4 and IE4/5 allow to cancel a key press with
  <INPUT TYPE="text" ONKEYDOWN="return false">
M13 just calls the handler but doesn't cancel the key press but displays all 
keys.

<SCRIPT>
function validateNonNumber (evt) {
  var keyCode = evt.which ? evt.which : evt.keyCode;
  return keyCode < '0'.charCodeAt() || keyCode > '9'.charCodeAt(); 
}
</SCRIPT>
</HEAD>
<BODY>
<FORM NAME="aForm">
<INPUT TYPE="text" NAME="field"
       ONKEYDOWN="return false"
>
<BR>
<INPUT TYPE="text" NAME="aField"
       ONKEYDOWN="return validateNonNumber(event)"
>
</FORM>

This is standard version 4 browser event handling stuff so it should work with 
NN5 even if DOM standards exclude key event handling
(Reporter)

Comment 1

18 years ago
Created attachment 5394 [details]
bug demo (first field should cancel any key, second any numerical)
Marking testcase and 4xp and m17.
Keywords: 4xp, testcase
Target Milestone: M17
(Assignee)

Comment 3

18 years ago
Adding [DOM] prefix to bugs related to DOM Level 0, 1, or 2 
compatibility/compliance.
Status: NEW → ASSIGNED
Summary: onkeydown="return false" doesn't cancel the key in INPUT TYPE="text" → [DOM] onkeydown="return false" doesn't cancel the key in INPUT TYPE="text"
(Assignee)

Comment 4

18 years ago
Updating Milestone to M18.
Target Milestone: M17 → M18

Comment 5

18 years ago
Mass update:  changing qacontact to ckritzer@netscape.com
QA Contact: janc → ckritzer

Comment 6

18 years ago
->saari for dup

Comment 7

18 years ago
no, really
Assignee: joki → saari
Status: ASSIGNED → NEW

Comment 8

18 years ago
PDT: Nominating nsbeta3+
Reason: HTML4 compliance, DOM compliance;

Updated

18 years ago
Keywords: nsbeta3

Comment 9

18 years ago
nominating, per ckritzer comment.

Comment 10

18 years ago
*** Bug 50469 has been marked as a duplicate of this bug. ***
While investigating bug 50478 it looks like the GetCancelable is implemented 
wrong, and probably we never set the cancelable property.

Comment 12

18 years ago
This event should also be cancelable by the DOM2 method preventDefault() on the 
event object.

Comment 13

18 years ago
nsbeta3+, p2 for M18
Priority: P3 → P2
Whiteboard: [nsbeta3+]

Comment 14

18 years ago
->joki, per saari
Assignee: saari → joki
(Assignee)

Comment 15

18 years ago
So we've had some discussion about this.  We have in the past allowed onkeydown 
to stop character input but we've encourage the use of onkeypress instead.  
Current specs in process seem to lean somewhat more towards this as well.  They 
may of course change.

For the moment in our current architecture it is easy to make 
'onkeypress="return false" work.  I have done this.  This will fix a number of 
similar cases and provide a workaround for anyone running into this.  It is much 
harder to do the same for onkeydown and it will not get done for this release.

I'm going to remove the nsbeta3 and set this bug to future.  I believe that with 
the workaround it is now a lower priority bug.  The break in compatibility is 
unfortunate but at the moment it seems to be necessary.
Status: NEW → ASSIGNED
Keywords: nsbeta3
Whiteboard: [nsbeta3+]
Target Milestone: M18 → Future

Comment 16

18 years ago
joki: Great, if I can do that with "onkeypress". The main use for canceling 
here is masked input.(textfields/textareas). If the "onkeypress" implementation 
will allow that, that's enough (for me, at least).

Comment 17

18 years ago
Updating QA Contact.
QA Contact: ckritzer → lorca

Comment 18

18 years ago
Um-call me silly, but is this bug very related to 
http://bugzilla.mozilla.org/show_bug.cgi?id=1572
If not entirely a duplicate?  Anyone?  You there, in the back?  Slap me if I just 
don't get it.

Comment 19

18 years ago
Yes, it seems to be a duplicte. This one has a testcase attached however.

Comment 20

18 years ago


*** This bug has been marked as a duplicate of 1572 ***
Status: ASSIGNED → RESOLVED
Last Resolved: 18 years ago
Resolution: --- → DUPLICATE
VERIFIED based on above comments.
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.