“Submit is not a function” error in JavaScript

后端 未结 15 2827
遇见更好的自我
遇见更好的自我 2020-11-22 00:10

Can anyone tell me what is going wrong with this code? I tried to submit a form with JavaScript, but an error \".submit is not a function\" shown. See below for more details

15条回答
  •  终归单人心
    2020-11-22 00:26

    I had the same issue when i was creating a MVC application using with master pages. Tried looking for element with 'submit' as names as mentioned above but it wasn't the case.

    For my case it created multiple tags on my page so there were some issues referencing the correct form.

    To work around this i'll let the button handle which form object to use:

    onclick="return SubmitForm(this.form)"
    

    and with the js:

    function SubmitForm(frm) {
        frm.submit();
    }
    

提交回复
热议问题