Closed
Bug 225214
Opened 22 years ago
Closed 22 years ago
when enter in <input type="text"> is pressed the onclick handler of an <input type="image"> is fired
Categories
(Core :: DOM: UI Events & Focus Handling, defect)
Tracking
()
RESOLVED
DUPLICATE
of bug 181067
People
(Reporter: martin.honnen, Unassigned)
Details
Attachments
(3 files)
In an HTML form there are some
<input type="image">
elements with onclick handlers and one
<input type="text">
element. When enter is pressed in the <input type="text"> control then the
onclick handler of the first <input type="image"> control is called.
Pressing enter in the <input type="text"> should not click any <input type="image">.
If the enter key is supposed to submit the form then the onsubmit handler of the
<form> element should be called, that is what happens with IE/Win.
Tested with Mozilla 1.5 (Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5)
Gecko/20031007) and with Netscape 7.1 (Mozilla/5.0 (Windows; U; Windows NT 5.1;
en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)).
I will upload a test case demonstrating the problem.
| Reporter | ||
Comment 1•22 years ago
|
||
| Reporter | ||
Comment 2•22 years ago
|
||
Comment 3•22 years ago
|
||
Happens also in Mozilla 1.6a on Windows 200 (build ID: 2003110115).
Comment 4•22 years ago
|
||
Note that if a form has an <input type="text"> and and <input type="submit"> and
you hit enter in the text input the onclick handler of the submit WILL fire
(that's why we fire onclick, in fact). Does IE treat image and submit inputs
differently here?
| Reporter | ||
Comment 5•22 years ago
|
||
| Reporter | ||
Comment 6•22 years ago
|
||
I have made a comparable test case with <input type="submit"> elements instead
of <input type="image"> elements:
http://bugzilla.mozilla.org/attachment.cgi?id=135180&action=view
When tested with Mozilla 1.5 it indeed is consistent here to the earlier test
case and again fires the onclick of the first submit button when enter is
pressed in the text control.
Neither Netscape 4 nor IE6 do that, they simply submit the form whereby the
onsubmit handler of the <form> is fired.
I think the Netscape 4/IE6 behaviour is more desirable, it is very confusing
that with Mozilla a submit button is clicked when you press enter in a text box.
Comment 7•22 years ago
|
||
Oh, now I recall this mess.
Here is the exact behavior breakdown by browser:
NS4: Will never fire onclick; enter will not submit forms with more than one
text input.
IE: Enter will submit forms with any number of text inputs. onclick will fire
if there is more than one text input (presumably for NS4 compat).
Mozilla: Enter will submit forms with any number of text inputs. onclick will
fire regardless of number of text inputs.
Unfortunately, we have found that a number of sites depend on the IE behavior in
the "multiple text inputs" case, which is why we implemented onclick firing at
all. But we see no reason not to fire it in the single-input case too, since
the page has to be able to deal with that eventuality anyway (the user may in
fact click the button or image). See bug 147850 for more details.
*** This bug has been marked as a duplicate of 181067 ***
Status: NEW → RESOLVED
Closed: 22 years ago
Resolution: --- → DUPLICATE
Updated•6 years ago
|
Component: Event Handling → User events and focus handling
You need to log in
before you can comment on or make changes to this bug.
Description
•