I have a form that will be submitted by javascript code triggered in "onsubmit" of the tag. Works fine on all browsers - but not on IE7/IE8.
What can I do?
<form action="/dosomething.htm" method="GET" onsubmit="submitmyform();return false">
[...]
<input type="submit" value="Go">
</form>
The solution for us was to move the javascript event from "onsubmit" of the form to "onclick" of the submit button.
The attach event method only works only for IE7/8. If you want a reliable cross browser solution you should use addEventListener as an alternative.
Hope it helps
Several ideas proposed here work (because they use different ways to write correct code), but there is a much easier answer
OP wrote :
instead of :
That's it.
I don't think your return false is ever reached, as it comes after what's returned from your function.
Make sure that you return false inside of your 'submitmyform()' function else, if it's not then it could be returning true to you form obsubmit event.
To cancel an event in legacy IE, you need to set
returnValue
tofalse
. Simply returningfalse
won't do it. I don't know why Microsoft implemented it in this way.