Languages
[Edit]
EN

HTML - submit input

6 points
Created by:
nickkk0
647

In this article, we would like to show you how to create submit input element that appears as button in HTML.

Quick solution:

 

Practical examples

Edit

1. Pure HTML form sending

Edit

In this example, we create a simple submit button that sends form using POST method to the /path/to/backend. That approach redirects page to /path/to/backend.

2. Form submit event handling with JavaScript - example 1

Edit

In this example, we handle submit action in JavaScript code. return false in onsubmit prevents web page reloading. Programmer should send data in own way in handleSubmit function, e.g. AJAX / fetch() function.

3. Form submit event handling with JavaScript - example 2

Edit

In this example, we handle submit action in JavaScript code. event.preventDefault() in handleSubmit prevents web page reloading. Programmer should send data in own way in handleSubmit function, e.g. AJAX / fetch() function.

References

Edit
  1. <input type="submit"> - HTML | MDN

Alternative titles

  1. HTML - input type submit
  2. HTML - submit button
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join