locked
Does IE11 treat every input button on web page as submit button? RRS feed

  • Question

  • Does IE11 treat every input button on web page as submit button?

    While doing testing for IE11 for our websites, users are reporting that hitting enter key while on any Page causes an action equivalent to some button click on the Page. We are thinking that button that loads first in the DOM cycle is what causes click event trigger on enter key press on Page. Seems like IE11 takes all buttons as Submit button?

    Can someone share if you have similar observation. What is best way to handle this?


    -http://lrathi.blogspot.com

    Tuesday, October 6, 2015 10:01 PM

Answers

  • Hi,

    using the dev tool (f12) you could view the event object.

    eg. form.onsubmit=function(evt){

    console.dir(evt);

    }

    and determine its target value.

    there are two types of input elements that behave as buttons.

    <input type="submit"/> and <input type="reset"/>

    as opposed to <button> elements (which default with type submit) which have three type values eg.

    <button type="submit"></button><button type="button"></button><button type="reset"></button>

    a common error is to place a button element without a type attribute value (default submit) outside of a form element.... by default the button element click will fire the form.submit event handler.

    Generally ALL of your form elements (tags input, button, select, textarea) must be children of the form element. You can list the form elements in the dev tool console with form.elements.

    If you are using asp.net with form-postback and/or masterpages, you can also define the default button on a form page which associates Enter keypress with the form.submit event handler.

    When possible please include a link to your website or a mashup (jsfiddle) with your questions.


    Rob^_^

    Tuesday, October 6, 2015 11:11 PM