title: difference between document.forms[0].onsubmit and jQuery("form").submit
body: <p>Why does <code>#1</code> get called when the <code>__doPostback</code> (this dynamic JavaScript function created automatically by ASP.NET when HTML renders.. I think when Event Validation is turned on) is called, but <code>#2</code> does not get called.  Yet, both get called when a button is clicked?</p>
  
  <h3>#1</h3>
  
  <pre><code>document.forms[0].onsubmit =
       function() {
       alert("called submit 1");
       jQuery("#&lt;%=DDLUCSAddress.ClientID %&gt;").children("option").each(function() {
       jQuery(this).remove();
     });
   };
  </code></pre>
  
  <h3>#2</h3>
  
  <pre><code>jQuery("form").submit(function() {
      alert("called submit 2");
      jQuery("#&lt;%=DDLUCSAddress.ClientID %&gt;").children("option").each(function() {
              jQuery(this).remove();
      });
  });
  </code></pre>
  
  <hr>
  
  <p>Rendered HTML - If I do a Ctrl+K+D on this code, it exceeds the character limit for Stack Overflow, due to the spaces.  If you'd like to look at it formatted, place into Visual Studio and press <code>Ctrl+K+D</code></p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;body&gt;
  &lt;div id="sessionRefresh" style="display:none"&gt;
  &lt;script language="JavaScript" type="text/javascript" /&gt;
  &lt;form id="Form1" onsubmit="javascript:return WebForm_OnSubmit();" action="EditSampleDetails.aspx?LabAccessioningNumber=20120401-1&amp;SampleTypeContext=247" method="post" name="Form1"&gt;
  &lt;div&gt;
  &lt;script type="text/javascript" /&gt;
  &lt;script type="text/javascript" src="/WebResource.axd?d=EXaDJPTWpPG72bTbiKNh_OuYVox46idcF5L2FHTyi19FoknASLIR-iSOhjjdC3Xa0OCTSAQepXg5UpNN1TPkcREtvcQ1&amp;t=634208598757546466" /&gt;
  &lt;script type="text/javascript" language="javascript" /&gt;
  &lt;script type="text/javascript" src="/WebResource.axd?d=4scrxOSLDbM-cgeLoXFnrTxM83c-T6NjCtRi_ghVZlXN0qjfjwNCtjtRWczFgkWux80g8Ip0p9JqPBJcPSlcT3N25CA1&amp;t=634208598757546466" /&gt;
  &lt;script type="text/javascript" /&gt;
  &lt;div&gt;
  &lt;div id="mainMenu" class="droplinetabs"&gt;
  &lt;table cellspacing="0" cellpadding="0" border="0"&gt;
  &lt;table class="uIBoxStacked" width="100%" cellspacing="0" cellpadding="0" border="0"&gt;
  &lt;tbody&gt;
  &lt;tr&gt;
  &lt;tr&gt;
  &lt;td class="uIBoxInternal" colspan="2"&gt;
  &lt;table width="100%" cellspacing="0" cellpadding="0" border="0"&gt;
  &lt;tbody&gt;
  &lt;tr&gt;
  &lt;td&gt;
  &lt;div id="BxWizardTitle" style="border-color:LightSteelBlue;width:100%;"&gt;
  &lt;a href='javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00", "", true, "", "", false, true))'&gt;&lt;/a&gt;
  &lt;a href='javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl01", "", true, "", "", false, true))'&gt;&lt;/a&gt;
  &lt;a href='javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl02", "", true, "", "", false, true))'&gt;&lt;/a&gt;
  &lt;a href='javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl03", "", true, "", "", false, true))'&gt;&lt;/a&gt;
  &lt;table cellspacing="0" cellpadding="0" style="border-width:0px;"&gt;
  &lt;tbody&gt;
  &lt;tr&gt;
  &lt;td class="leftNavigationCell" style="vertical-align:top;"&gt;
  &lt;td&gt;
  &lt;td valign="top"&gt;
  &lt;table cellpadding="5"&gt;
  &lt;tbody&gt;
  &lt;tr&gt;
  &lt;tr&gt;
  &lt;td&gt;
  &lt;table cellpadding="5"&gt;
  &lt;tbody&gt;
  &lt;tr&gt;
  &lt;tr&gt;
  &lt;tr&gt;
  &lt;td&gt;
  &lt;script type="text/javascript" /&gt;
  &lt;table class="uIBoxStacked" width="100%" cellspacing="0" cellpadding="0" border="0"&gt;
  &lt;tbody&gt;
  &lt;tr&gt;
  &lt;tr&gt;
  &lt;td class="uIBoxInternal" colspan="2"&gt;
  &lt;table class="outerTableOfInputs" width="100%" cellspacing="0"&gt;
  &lt;tbody&gt;
  &lt;tr&gt;
  &lt;td&gt;
  &lt;table class="tableOfInputs" width="100%" cellspacing="0"&gt;
  &lt;tbody&gt;
  &lt;tr&gt;
  &lt;td&gt;
  &lt;div id="FullDataEntryEditor_UIBSampleInfo" style="border-color:LightSteelBlue;width:100%;"&gt;
  &lt;a href='javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("FullDataEntryEditor$ctl00", "", true, "", "", false, true))'&gt;&lt;/a&gt;
  &lt;a href='javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("FullDataEntryEditor$ctl01", "", true, "", "", false, true))'&gt;&lt;/a&gt;
  &lt;a href='javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("FullDataEntryEditor$ctl02", "", true, "", "", false, true))'&gt;&lt;/a&gt;
  &lt;a href='javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("FullDataEntryEditor$ctl03", "", true, "", "", false, true))'&gt;&lt;/a&gt;
  
  &lt;table&gt;
  &lt;script type="text/javascript" /&gt;
  &lt;tbody&gt;
  &lt;tr&gt;
  &lt;tr&gt;
  &lt;tr&gt;
  &lt;tr&gt;
  &lt;td&gt;Additional Client Number&lt;/td&gt;
  &lt;td&gt;
  &lt;input id="FullDataEntryEditor_TxtAdditionalClientNumber" class="LIMSFormField" type="text" autocomplete="off" name="FullDataEntryEditor$TxtAdditionalClientNumber"&gt;
  &lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;tr&gt;
  &lt;tr&gt;
  &lt;tr&gt;
  &lt;tr&gt;
  &lt;tr&gt;
  &lt;tr&gt;
  &lt;tr&gt;
  &lt;tr&gt;
  &lt;/tbody&gt;
  &lt;/table&gt;
  &lt;/div&gt;
  &lt;/td&gt;
  &lt;/tr&gt;
  &lt;/tbody&gt;
  &lt;/table&gt;
  &lt;/td&gt;
  &lt;/tr&gt;
  &lt;/tbody&gt;
  &lt;/table&gt;
  &lt;/td&gt;
  &lt;/tr&gt;
  &lt;/tbody&gt;
  &lt;/table&gt;
  &lt;table class="saveCancelDeleteOuter" width="100%" cellspacing="0"&gt;
  &lt;table width="100%" cellspacing="0" cellpadding="0" border="0"&gt;
  &lt;tbody&gt;
  &lt;tr&gt;
  &lt;td&gt;
  &lt;input id="EditObjectId986257676" type="hidden" value="" name="EditObjectId986257676"&gt;
  &lt;input id="CommandName986257676" type="hidden" value="" name="CommandName986257676"&gt;
  &lt;table class="uIBoxStacked" width="100%" cellspacing="0" cellpadding="0" border="0"&gt;
  &lt;tbody&gt;
  &lt;tr&gt;
  &lt;tr&gt;
  &lt;tr&gt;
  &lt;td class="uIBoxInternal" colspan="2"&gt;
  &lt;table width="100%" cellspacing="0" cellpadding="0" border="0"&gt;
  &lt;tbody&gt;
  &lt;tr&gt;
  &lt;td&gt;
  &lt;div id="FullDataEntryEditor_NMNotes_List_ListBox" style="border-color:LightSteelBlue;width:100%;"&gt;
  &lt;a href='javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("FullDataEntryEditor$NMNotes$List$ctl00", "", true, "", "", false, true))'&gt;&lt;/a&gt;
  &lt;a href='javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("FullDataEntryEditor$NMNotes$List$ctl01", "", true, "", "", false, true))'&gt;&lt;/a&gt;
  &lt;a href='javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("FullDataEntryEditor$NMNotes$List$ctl02", "", true, "", "", false, true))'&gt;&lt;/a&gt;
  &lt;a href='javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("FullDataEntryEditor$NMNotes$List$ctl03", "", true, "", "", false, true))'&gt;&lt;/a&gt;
  &lt;table id="FullDataEntryEditor_NMNotes_List_ListGrid" cellspacing="0" cellpadding="4" border="1" style="width:100%;border-collapse:collapse;" rules="all"&gt;
  &lt;tbody&gt;
  &lt;tr class="columnHeader"&gt;
  &lt;tr style="background-color:Yellow;"&gt;
  &lt;td&gt;
  &lt;a href="javascript:listCustomPostback(986257676,'Edit',129285);"&gt;bbbbbbbbbbbbbb&lt;/a&gt;
  &lt;/td&gt;
  &lt;td&gt;
  &lt;/tr&gt;
  &lt;/tbody&gt;
  &lt;/table&gt;
  &lt;/div&gt;
  &lt;/td&gt;
  &lt;/tr&gt;
  &lt;/tbody&gt;
  &lt;/table&gt;
  &lt;/td&gt;
  &lt;/tr&gt;
  &lt;/tbody&gt;
  &lt;/table&gt;
  &lt;div id="pdfDisplay"&gt;&lt;/div&gt;
  &lt;script language="javascript" type="text/javascript" /&gt;
  &lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;/tbody&gt;
  &lt;/table&gt;
  &lt;script type="text/javascript" /&gt;
  &lt;input id="FullDataEntryEditor_HiddenSampleType" type="hidden" value="247" name="FullDataEntryEditor$HiddenSampleType"&gt;
  &lt;input id="FullDataEntryEditor_HiddenAJAXUCSAddressValue" type="hidden" value="7533" name="FullDataEntryEditor$HiddenAJAXUCSAddressValue"&gt;
  &lt;input id="FullDataEntryEditor_HiddenAJAXUCSAddressText" type="hidden" value="[7533] A1's Primary address, a1_primary_address, madison wi, usa 53719" name="FullDataEntryEditor$HiddenAJAXUCSAddressText"&gt;
  &lt;/td&gt;
  &lt;/tr&gt;
  &lt;/tbody&gt;
  &lt;/table&gt;
  &lt;/td&gt;
  &lt;/tr&gt;
  &lt;/tbody&gt;
  &lt;/table&gt;
  &lt;/td&gt;
  &lt;/tr&gt;
  &lt;/tbody&gt;
  &lt;/table&gt;
  &lt;/div&gt;
  &lt;/td&gt;
  &lt;/tr&gt;
  &lt;/tbody&gt;
  &lt;/table&gt;
  &lt;/td&gt;
  &lt;/tr&gt;
  &lt;/tbody&gt;
  &lt;/table&gt;
  &lt;table class="saveCancelDeleteOuter" width="100%" cellspacing="0"&gt;
  &lt;script type="text/javascript" /&gt;
  &lt;script type="text/javascript" /&gt;
  &lt;script type="text/javascript" /&gt;
  &lt;/form&gt;
  &lt;table class="copyright" align="center"&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>