Enter key wont submit form in IE6
I have a form like this:
<form id="form_main" name="form_main" action="/search/" target="iframe001" method="get" onSubmit="reset_and_subm();">
Enter key wont submit this form in IE6, but will in Chrome, FF, Opera, Safari, and IE8 (haven't tested IE7 yet). IN FACT, NOT EVEN PRESSING THE SUBMIT BUTTON SUBMITS THE FORM. I have tried for hours now... What could be the problem? I have tried this:
<for开发者_C百科m id="form_main" name="form_main" action="/search/" target="iframe001" method="get" onSubmit="alert('hello');">
And the alertbox comes up with the message...
Now here is the function "reset_and_subm();"
function reset_and_subm(){
document.getElementById("p").value = 1;
return true;
}
Does anybody know what I should do here?
Btw, I have checked all inputs in the form, and all seem okay... So assume there is nothing wrong with the content of the form.
Thanks
UPDATE:
I have a submit button yes. The entire form content is way to large to put here, but it contains only one textfield. The rest is "selects" and "hidden inputs". I am pressing enter in the only textfield there is... Also I have added the code of the submit button:
<input name="nav_querystring" type="text" id="nav_querystring" style="width: 240px; font-family:Arial, Helvetica, sans-serif; font-size:12px; font-weight:bold;" value="">
<input type="submit" name="nav_submit" id="nav_submit" value="Sök" style="width: 55px; font-size: 13px;">
UPDATE2:
Just to point out, I have included the js file which contains the function "reset_and_subm" and also, I am using mod_rewrite in .htaccess to rewrite the action of the form. I hope none of this is causing the issue.
UPDATE3: Seems the problem might lie in the body OnLoad eventy, where I have a js function not listed here. Doesn't IE6 support OnLoad? What should I use instead...
Here is my current code:
<body onLoad="subSelection();">
Thanks
I have made two changes to your code.
As you are calling a function from onsubmit, I have included the "return" keyword in the method call.
As the form only has one form element, I have added a hidden element to the form.
<form id="form_main" name="form_main" action="/search/" target="iframe001" method="get" onSubmit="return reset_and_subm();">
<div style="display: none;"><input type="text" name="ie6"></div>
<input name="nav_querystring" type="text" id="nav_querystring" style="width: 240px; font-family:Arial, Helvetica, sans-serif; font-size:12px; font-weight:bold;" value="">
<input type="submit" name="nav_submit" id="nav_submit" value="Sök" style="width: 55px; font-size: 13px;">
</form>
Please shout if you are still stuck.
I seem to remember there is a strange bug with only one text box on a page in IE6 that we had to work around a long time ago. Try putting another empty textbox on the page with its style set to display: none and see if that works. It might sound crazy but that's what happens with crazy IE bugs...
There is a bug in IE where forms with a single text field won't submit when pressing the "enter/return" key. The solution is to add a second field : Simples :D
精彩评论