Oh, sorry. You're right.

Didn't saw that this script is invoked by a js command submit(). But if you click on the browser "submit" button you need to be careful, because the browser executes onsubmit:

<html>
        <body>
                <form id="theForm" onsubmit="alert('form onsubmit');return 
true;">
                        <input type="submit" value="submit" />
<input type="button" onclick="document.forms['theForm'].submit();" value="button test js submit">
                </form>
        </body>
</html>

On Wed, 28 Sep 2005 23:21:09 +0200, Matt Blum <[EMAIL PROTECTED]> wrote:

No, it's not. When you invoke the submit method on a form, its onsubmit
handler is not executed at all. That's the reason this code is necessary in
the first place.

-Matt

On 9/28/05, Paul Klaer <[EMAIL PROTECTED]> wrote:

Be careful with that script!

Your onsubmit method is executed twice if it will return a value true!

You have to use this code:

if(document.forms['body:theForm'].onsubmit) {
document.forms['body:theForm'].submit();
} else {
document.forms['body:theForm'].submit();
}

otherwise:

if(document.forms['body:theForm'].onsubmit) {
if(document.forms['body:theForm'].onsubmit()) <<<<<<<- onsubmit is
executed here and if it returns true submit
document.forms['body:theForm'].submit(); <<<<<<<-- and onsubmit is
executed here
} else {
document.forms['body:theForm'].submit();
}

On Wed, 28 Sep 2005 03:24:06 +0200, Saul Qunming Yuan <[EMAIL PROTECTED]>
wrote:

> if(document.forms['body:theForm'].onsubmit) {
> if(document.forms['body:theForm'].onsubmit())
> document.forms['body:theForm'].submit();
> } else {
> document.forms['body:theForm'].submit();
> }





Reply via email to