If you have came accross this problem then you are at right place for the solution. I have the same problem and I was not sure what the real problem is. I was just about to bang my head on WALL :).
But hopefully I have found the solution for the same. But first let me explain what the scenario is:
I had one simple HTML form and have done JS validation and coded to submit the form using document.getElementById('form_id').submit(); method.
But whenever I call this submit method I was getting below error:
Uncaught TypeError: Property ‘submit’ of object #<HTMLFormElement> is not a function
As you can see the problem is tricky so solution is also quite tricky. The real problem is with the name and/or id of your submit button. Surprised????
Yes the problem was the name attribute of the submit button in form which I was trying to submit.
Let’s say if your form element has a button with ID/name “submit”. When you trigger form.submit(), browser actually tries to run button element as a function instead of running the form’s submit function.
If you are not trusting me about the possibility of this problem then create one HTML file and place below html form code in that file, here you can notice the name of the submit button is “submit”. This problem may occur when you have is set to submit.
Avinash Zala currently working at a leading web development company as a Sr. PHP Web Developer. He is the founder of the Xpert Developer. He has completed B.E. in Information Technology. Born and brought up in Ahmedabad. He loves to code and coding is all about passion for him. Follow him on twitter at Avinash Zala & Xpert Developer.
View all posts by: Avinash