IE10 find the first button on the page and fire the click event on the submit input

Sorry for the headline, I know its mess, but I don't know how I can describe this situation.

we have an input field. but not an element of form. here is the code

<input name="search" id="search" onkeypress="SearchBox(this.value);" type="text" value="Search"/> <input name="searchbutton" align="left" class="okbutton" id="searchbutton" onclick="SearchBox(search.value);" type="button"/> 

The search function in SearchBox checks the key code and, if it is 13 (character input), sends a search request. this code works in IE8 / 9, but there is an interesting behavior in IE10.

Above average page code. and we have a button element at the top of the page for LOGIN.

in IE10;

i enter the word in the input and press enter:

  • SearchBox function work,
  • but behave the same as the LOGIN button, and the problem is with it

Note: sorry for the language, English is not my native language. Note 2: SearchBox () has been removed. check jsfiddle link for latest code.

+8
javascript submit internet-explorer-10 forms
source share
3 answers

another solution

Define the type of buttons as a button. because the default type represents

 <button type="button" .... 
+18
source share

Well, IE10 for Windows7 is a preview release, and that seems to be one of the things that MS needs to fix. In any case, I don’t know why this is happening, but I found a workaround for the problem:

Instead of button use <input type="button"> .

Live demo on jsFiddle .

+3
source share

I had the same problem. Adding type = "button" for all my buttons. <button type = "button"> ...

Even if my buttons are not in shape.

From another testing I did, IE 10 works exactly the same as Chrome. This is the only exception I've seen.

0
source share

All Articles