How to submit an HTML Form using JQuery

H

How Can We Help?

For example you have a form with id “myform

<form id="myform" action="submit.php">
  <input type="text" value="This is a test form" />
  <input type="button" id="mybutton" value="Save" />
</form>

Now  when the button with id “mybutton” is clicked we want to submit the form using the JQuery submit() function which executes each time the specified event is triggered. The code looks like the below 

<script type="texxt/javascript">
$('#mybutton').click(function() {
  $('#myform').submit();
});
 
</script>

Now whenever the Button with  id “mybutton is clicked the form will submit to the submit.php page.

About the author

Ian Carnaghan

I am a software developer and online educator who likes to keep up with all the latest in technology. I also manage cloud infrastructure, continuous monitoring, DevOps processes, security, and continuous integration and deployment.

About Author

Ian Carnaghan

I am a software developer and online educator who likes to keep up with all the latest in technology. I also manage cloud infrastructure, continuous monitoring, DevOps processes, security, and continuous integration and deployment.

Follow Me