How To

How to Submit Form Without Submit Button

There are several ways to submit a form. Generally, we are used to submit a form using a submit button. However, sometimes we have to submit a form using a specific event or by clicking an HTML element.

There are several ways to submit a form using JavaScript. Even more, we can also submit a form on some event on the webpage.

Here we are going to learn to submit a form without the submit button.

Submit a Form Using JavaScript

The most simple way to submit a form without the submit button is to trigger the submit event of a form using JavaScript.

In the below example we are going to create a function to submit a form. We will set that function at onclick event of a div tag.

<!DOCTYPE html>
<html>
  <head>
   <title>Submit a form using JavaScript onclick event</title>
  </head>
  <body>
    <form id="my_form" action-xhr="#" method="POST">
        <input type="text" name="name" placeholder="Enter Your Name"/>
        <br/>
        <input type="email" name="email" placeholder="Enter Your E-mail"/>
        <br/>
        <textarea placeholder="Enter Your Message" name="message"></textarea>
        <br/>
        <div >

Read Also: OnClick Form Validation Using jQuery

Conclusion

Here we submitted the form using a JavaScript function onclick event of div element. We can also set many other types of events to submit a form. I hope now you understand how to submit a form using JavaScript event without a submit button.

Enjoy Scripting 🙂

Nachiket Panchal

Founder & Administrator of `errorsea` Having interest in Programming & Technology.

Recent Posts

5 Important Things To Know About WordPress Before You Use It

There is a reason big-name companies like CNN use WordPress. WordPress is a popular content…

3 years ago

How to Install MySQL on Your PC in 3 Easy Steps

In this tutorial, I'm going to show you how to install MySQL on your computer.…

4 years ago

Download and Install Turbo C++ for Windows 10 (Full Installation Guide)

Download Turbo C++ for windows 10 in just 7 Mb and run your first C++…

5 years ago

PHP .HTACCESS Redirects

We can redirect any webpage to any other or redirect the whole domain or website…

5 years ago

PHP Redirect Pages

There are lots of methods to redirect pages, like refresh-redirect from META tag, redirect from…

5 years ago

PHP Include & Required

Include files in PHP are used in appending various global or config files. We can…

5 years ago