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>
I'm going to nitpick this. If you want to handle form submissions, that is what submit is for. If the user hits enter in one of your fields, your onclick handler will be totally avoided. Here is a basic example of doing this in a non-obtrusive way.
This can be made a lot simpler with jQuery, same form...
I had the same error and when I turned on the console, it never came. So I figured out, it was the console, that wasnt known by the internet explorer as long as it is turned off. Simply add a dummy console to the window with the following code (if there isnt already one):
With this you could get in trouble, if you want to have microsofts javascript console. Then just comment the lines out. But now, the console object is not undefined anymore on the whole site.
I think that the problem is in return false you need to return it from your 'onsubmit' function
see example.
This form will never be submitted in IE 7/8 as well.
Danny.
try this. work for me.
In fact, because you write
submitmyform();return false
onlysubmitmyform
is evaluated.In the case of two commands, you will have to put them between braces like this
so that both are evaluated.