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
Jquery Set Cursor Position in Text Area
How to Load an HTML Page in a Div Using JavaScript
Jquery: Get Height of Hidden Element in Jquery
Cross-Browser Multi-Line Text Overflow With Ellipsis Appended Within a Fixed Width and Height
How to Make Ng-Bind-Html Compile Angularjs Code
How to Convert Characters to HTML Entities Using Plain JavaScript
Transfer Data from One HTML File to Another
Pass a String Parameter in an Onclick Function
Offsetting an HTML Anchor to Adjust For Fixed Header
How to Check File Mime Type With JavaScript Before Upload
Maximum Size of a ≪Canvas≫ Element
How Can JavaScript Upload a Blob
Replacing CSS File on the Fly (And Apply the New Style to the Page)
Why Does This Simple Jsfiddle Not Work
Show Datalist Labels But Submit the Actual Value
After Submitting a Post Form Open a New Window Showing the Result