I have been using javascript to submit HTML forms at times for some convinence. I would like to know wheather there is any drawbacks of this approach compared to using classic form submit using a submit button
Using plain HTML is better for many reasons:
- If your user does not have JavaScript enabled, or you havea JavaScript bug in your code, your form still works.
- Plain HTML forms are simpler to write, and harder to screw up
- An actual button is better semantically than a magic link or div that submits the form for you. This helps with things like tab ordering, OS integration, screen readers, and is clearer to programmers who work on the code after you.
- The browser already has battle tested code to submit forms. Why would you rewrite that code for no point? It increases risk, complexity and time.
- Not writing the JavaScript code means you have more time for other things, like not working on the code anymore.
If something already exists and works for your use case, don't reinvent the wheel!