Closed Bug 28323 Opened 25 years ago Closed 24 years ago

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

Categories

(Core :: DOM: UI Events & Focus Handling, defect, P2)

x86
Windows 98
defect

Tracking

()

VERIFIED DUPLICATE of bug 1572
Future

People

(Reporter: martin.honnen, Assigned: joki)

References

Details

(Keywords: testcase)

Attachments

(1 file)

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
Marking testcase and 4xp and m17.
Keywords: 4xp, testcase
Target Milestone: M17
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"
Updating Milestone to M18.
Target Milestone: M17 → M18
Mass update: changing qacontact to ckritzer@netscape.com
QA Contact: janc → ckritzer
->saari for dup
no, really
Assignee: joki → saari
Status: ASSIGNED → NEW
PDT: Nominating nsbeta3+ Reason: HTML4 compliance, DOM compliance;
Keywords: nsbeta3
nominating, per ckritzer comment.
*** 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.
This event should also be cancelable by the DOM2 method preventDefault() on the event object.
nsbeta3+, p2 for M18
Priority: P3 → P2
Whiteboard: [nsbeta3+]
->joki, per saari
Assignee: saari → joki
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
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).
Updating QA Contact.
QA Contact: ckritzer → lorca
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.
Yes, it seems to be a duplicte. This one has a testcase attached however.
*** This bug has been marked as a duplicate of 1572 ***
Status: ASSIGNED → RESOLVED
Closed: 24 years ago
Resolution: --- → DUPLICATE
VERIFIED based on above comments.
Status: RESOLVED → VERIFIED
Component: Event Handling → User events and focus handling
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: