OnClick does not start only one input when you press enter

I'm having issues with events in Internet Explorer 7.

When I have a form with two or more input[type=text] and I press enter, the events happen in the following order:

  • submit button ( onClick)
  • form ( onSubmit)

Code example:

<form onSubmit="{alert('form::onSubmit'); return false;}">
    <input type="text">
    <input type="text">
    <input type="submit" onClick="{alert('button::onClick');}">
</form>

If I have only one input[type=text] , and I press the enter button, the button onClickdoes not work. Code example:

<form onSubmit="{alert('form::onSubmit'); return false;}">
    <input type="text">
    <input type="submit" onClick="{alert('button::onClick');}">
</form>
+5
source share
6 answers

onclick ( ) , ( ), , .

, , (, )?

+4

. .

- javascript , onsubmit ( false ), script onClick . javascript , type = "button" type = "submit" - , ,

+3

, , onSubmit.

, , , , , type = "submit".

+1

, ( ) , onClick... , , .
, , onClick .
onSubmit , "" , .

+1

DOCTYPE, , ? DOCTYPE - , quirks - , , - .

+1

, , , ... , ,

<FORM onSubmit="{alert('form::onSubmit'); return false;}">
    <INPUT TYPE="text">
    <input type="hidden" name="dummy">
    <INPUT TYPE="submit" onClick="{alert('buttom::onClick');}">
</FORM>

IE , .

0

All Articles