"Submit Is Not a Function" Error in JavaScript

Submit is not a function error in JavaScript

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.

Uncaught TypeError: form.submit is not a function in form validate() function

You most probably have a button or input in your form with id="submit" and/or name="submit" like this:

<form>
<input type="text" name="someName" />
<input type="email" name="someEmail" />
<!-- Other form elements -->
<button type="submit" name="submit" id="submit">Submit</button>
</form>

This will change form.submit() to a field reference rather than a method call. You can verify this by console logging form.submit() which will most probably return the <button type="submit" name="submit" id="submit">Submit</button> element instead.

To fix this, you need to either remove the id="submit" and/or name="submit" attributes or change them to something else like this:

<form>
<input type="text" name="someName" />
<input type="email" name="someEmail" />
<!-- Other form elements -->
<button type="submit" name="submitBtn" id="submitBtn">Submit</button>
</form>

And again: submit is not a function

You are pointing the input, not the form, which is the element who will submit the form.

const sendit = document.getElementById("form");

Your function that submits the form, has to point to the form id form. You are pointing a button, which doesn't have the submit event.

jQuery Uncaught TypeError: submit is not a function

Remove the " " on the line : formTo = "$('#" + formTo + "')"; in formTo = $('#' + formTo); because you build a String object and not a Jquery one so you try to submit a string and throw an error



Related Topics



Leave a reply



Submit