"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.
If you have no opportunity to change name="submit"
you can also submit form this way:
function submitForm(form) {
const submitFormFunction = Object.getPrototypeOf(form).submit;
submitFormFunction.call(form);
}
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.