“Submit is not a function” error in JavaScript

“Submit is not a function” error in JavaScript

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 of the code:

I also tried this:

Both show me the same error 🙁


Solution 1:

submit is not a function

means that you named your submit button or some other element submit. Rename the button to btnSubmit and your call will magically work.

When you name the button submit, you override the submit() function on the form.

Solution 2:

<form action="product.php" method="post" name="frmProduct" id="frmProduct" enctype="multipart/form-data">

<input id="submit_value" type="button" name="submit_value" value="">


<script type="text/javascript">

document.getElementById("submit_value").onclick = submitAction;

function submitAction()
    return false;

EDIT: I accidentally swapped the id’s around

Solution 3:

Make sure that there is no another form with the same name and make sure that there is no name=”submit” or id=”submit” in the form.

Solution 4:

If you have no opportunity to change name="submit" you can also submit form this way:

function submitForm(form) {
    var submitFormFunction = Object.getPrototypeOf(form).submit;

Solution 5:

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.

Related:  RxJs Observable of vs from

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) {

Solution 6:

giving a form element a name of submit will simple shadow the submit property .
make sure you don’t have a form element with the name submit and you should be able to access the submit function just fine .