I have an input element with onchange=”do_something()”. When I am typing and hit the enter key it executes correctly (do_something first, submit then) on Firefox and Chromium (not tested in IE and Safari), however in Opera it doesn’t (it submits immediately). I tried using a delay like this:
<form action="." method="POST" onsubmit="wait_using_a_big_loop()">
<input type="text" onchange="do_something()">
</form>
but it didn’t work either.
Do you have some recommendations?
Edit:
Finally I used a mix of the solutions provided by iftrue and crescentfresh, just unfocus the field to fire do_something() method, I did this because some other input fields had others methods onchange.
$('#myForm').submit( function(){
$('#id_submit').focus();
} );
Thanks
You could use jquery and hijack the form.
http://docs.jquery.com/Events/submit
This should submit the form after calling that method. If you need more fine-grained control, throw a return false at the end of the submit event and make your own post request with $.post();