Dating from the introduction of Javascript by Netscape Corporation, form element event handlers defined as HTML attribute values were provided with a special scope chain which searches properties of the element clicked and the form element ahead of searching the global object. [This was a convenience for web programmers and predated the introduction of a Document Object Model with standardized methods for access and manipulation.] Hence
<input type="button" value="Submit!" onClick="submit()" />
when clicked executes the anonomous function created from the HTML attribute string:
function( event) { submit()}
which searches its scope chain for submit
and finds it as a property of the enclosing form
object. Possible solutions include
explicitly specifying the global version of the function to execute:
onclick="window.submit()"
naming the global function something else, say "preSubmit", which does not conflict with the property of the form object:
onclick="preSubmit()"
adding the click event handler to the button in javascript after the button element has been created (only function specified in HTML have a special scope chain).
Section `19.1.6. Scope of Event Handlers" within chapter 19 of "Javascript the Definitive Guide" from O'Reilly is the only link that I have been able to find which discusses this.
updated after @progysm's comment on another answer
The scope chain of an HTML provided event handler is now covered in the HTML5 standard, under internal raw uncompiled handler, list item 1.10, which indicates the lexical scope of the handler includes the element clicked, the form it belongs to (if any) and the document object. I would caution against relying on this too heavily: some browsers used to include every parent object of a clicked element in its scope chain, not just its form and document.