Online Snippets Library

Submit form using jQuery

To submit form, we use submit() method of jQuery.

Syntax

$(selector).submit()

Example

HTML
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-1.11.2.min.js"> </script>
<title>Submit form using jQuery</title>
</head>
<body>
<form id="formId" runat="server" method="post">
Email: <input type="text" name="email" value="[email protected]">
<input type="button" value="Submit" id="button">
</form>
</body>
</html>
Javascript
$(document).ready(function(){
$("#button").click(function(){
  alert("Form has been submitted successfully.");
  $("#formId").submit();
 });
 });