Suggestion.. return an error code from trigger(), submit(),etc functions if the following condition exists..

Suggestion.. return an error code from trigger(), submit(),etc functions if the following condition exists..

<!--
    Suggestion.. return an error code from trigger(), submit() etc if the following condition exists..
   
    If you have an input element in a form with the name or id of 'submit', it will cause the $form.submit()/trigger("submit") call to fail.
   
    Reason, the input element with name/id 'submit' is put into the form DOM element as { submit: <elements html> }
   
    Line of code failing in jQuery:
    line 1889: jquery-1.4.2 (uncompressed)

    target[ type ]();
   
    target is the form object in this case, type = "submit"
    target[type]() is trying to execute the input element's html instead of the correct submit() function
   
    how to check for this condition:
   
    if( isFunction( target[type]))
        target[type]();
    else
        return errorCode;

    No way to work around this problem afaik. This is happening with the DOM    . The only thing you can do is notify the user of an error condition.
   
    I spent several hours debugging this problem and later found that others had the same problem with jQuery as well as javascript in general. A note in the jQuery documentation to notify users of this condition would be helpful.
   
    The following code demonstrates the problem:
   
    Press "submit form f1" button and you won't see a form submission (check url)
    Press "submit form f2" button and you will see a form submission with the appropriate URL
    Press "clear url" button to clear your url,

Good luck,
rsepulveda
-->

<html>
  <head>
     <script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.js"></script>     
  </head>
<body>

<form id="f1" action="#">
    <input type="hidden" name="form1" value="was submitted" />
    <input id="b1" type="submit" name="submit" value="submit form f1" />   
</form>

<form id="f2" action="#">
    <input type="hidden" name="form2" value="was submitted" />
    <input id="b2" type="submit" name="submit2" value="submit form f2"/>
</form>

<form id="f3" action="#" />

<input type="submit" id="subf3" value="clear url"/>

<script>

$("#b1").click( function(){
        $("#f1").submit();
        return false;
    });

$("#b2").click( function(){
        $("#f2").submit();
        return false;
    });

$("#b3").click( function(){ // clear url
        $("#f3").submit();
        return false;       
    });

</script>

</body>
</html>