Есть код:
<body>
   <script type="text/javascript" language="Javascript">
      function doSubmit(){
         alert("AAAAAAAAAAAAAAAAAAAAAAAAAA!");
         return false;
      }
   </script>
   <form action="test.jsp" id="test" method="post" onSubmit="return doSubmit()">
      ...
   </form>
</body>

В итоге, при вызове document.getElementById("test").submit() функция doSubmit() не срабатывает. В чем я ошибся? :|

Не знаю. Но можно так:

Выделить код

Код:

<body>
   <script type="text/javascript" language="Javascript">
      function doSubmit(){
         alert("AAAAAAAAAAAAAAAAAAAAAAAAAA!");
         return false;
      }
   </script>
   <form action="test.jsp" id="test" method="post" onSubmit="return doSubmit()">
      ...
      <input type="submit" id="test2"/>
      ...
   </form>
</body>

+
document. getElementById("test2").click();

собственно dosubmit по документации и не должен вызываться на сколько я помню (давно уже читал)

DOM Level 2
Note: The onsubmit even handler is not guaranteed to be triggered when invoking this method. The behavior is inconsistent for historical reasons and authors should not rely on a particular one.

DOM Level 2 HTML Issues List
Description:
Microsoft (MSDN site) claims that the submit method of a form does not invoke the onsubmit event handler.

Microsoft goes on to claim on the same page that this method (submit method) is defined in the W3C DOM Level 1.

The reference I find for the HTMLFormElement in the DOM is section 2.5.5. Object Definitions. Here it defines the submit method as performing the same action as a submit button which implies invoking the onsubmit event.

I cannot find any specific reference here for whether or not the onsubmit event should or should not be included.

Can you clarify this please because I believe not calling an onsubmit method if one is defined for a form would be a violation of the W3C L1 DOM?

Resolution:
Unfortunately, given the differences between implementations, it was not possible to find a common ground on this issue. No changes were in the specification. You cannot rely on having an event when invoking the submit() method.

Спасибо.