Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

submit form on 'enter' in IE "web browser"

having a problem with the number one browser for downloading another browser...IE

IE8 fails to submit when you hit enter in a form. here is what i use:

function submitOnEnter() {
    if (browserName=="Microsoft Internet Explorer")
    {
        var key;

        if (window.event){
            key = window.event.keyCode; //IE
        }

        if(key == 13){
          document.forms['myform'].submit();
        }
    }
}

and this is located on the text input :

 onkeyup="submitOnEnter()"

The form seems to submit when i press enter twice?? but not once.

Can you help?

like image 279
c14kaa Avatar asked Jan 17 '11 16:01

c14kaa


1 Answers

Okay guys, i fixed it using....

  <!-- Fix for IE bug (One text input and submit, disables submit on pressing "Enter") -->    
  <div style="display:none">                 
  <input type="text" name="hiddenText"/>     
  </div> 

Weird eh? Maybe this will work for some of you and not others. some solutions didnt work for me, this one did.

like image 79
c14kaa Avatar answered Oct 04 '22 19:10

c14kaa