title: How to reliably submit an HTML form with JavaScript?
body: <p>Is there a way to submit an HTML form using <a href="http://en.wikipedia.org/wiki/JavaScript" rel="noreferrer">JavaScript</a> that is guaranteed to work in all situations?</p>
  
  <p>I elaborate. The common approach seems to be:</p>
  
  <pre><code>formElement.submit()
  </code></pre>
  
  <p>That is all good and well except for one thing. Fields of a form are available as attributes of <code>formElement</code>, so if there is a field with <strong>name</strong> or <strong>id</strong> "text1", it can be accessed as <code>formElement.text1</code>.</p>
  
  <p>This means that if an elements is called "submit" (be it its <strong>name</strong> or its <strong>id</strong>), then <code>formElement.submit()</code> will not work. This is because <code>formElement.submit</code> won't be a method of the form, but the field with that name. Unfortunately, it's fairly common that submit buttons have a "submit" name or id.</p>
  
  <p>Two examples to illustrate my point. First, the following will NOT work, because an element of the form has name "submit":</p>
  
  <pre><code>&lt;form name="example" id="example" action="/"&gt;
    &lt;button type="button" name="submit" onclick="document.example.submit(); return false;"&gt;Submit&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>The following will work though. The only difference is that I have removed the name "submit" from the form:</p>
  
  <pre><code>&lt;form name="example" id="example" action="/"&gt;
    &lt;button type="button" onclick="document.example.submit(); return false;"&gt;Submit&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>So, is there any other way to submit an HTML form using JavaScript?</p>