Share on Google+Share on Google+

jQuery 'submit' form event

In this tutorial, we will discuss about the 'submit' form event of jQuery.

jQuery 'submit' form event

In this tutorial, we will discuss about the  'submit' form event of jQuery. In this example , In this example a text box and a button is given, when we hit the button, it will check/validate whether entered string is  "true" or not. If it is 'true' , it will show a message "Query is validated" and also a alert box to show the "success" message. The alert box will show only when "submit" event return 'true' to 'form'.


<!DOCTYPE html>

p { margin:0; color:blue; }
div,p { margin-left:10px; }
span { color:red; }
<script src="jquery-1.4.2.js"></script>
<p>Type 'true' to validate.</p>
<form action="javascript:alert('success!');">
<input type="text" />

<input type="submit" />

$("form").submit(function() {
if ($("input:first").val() == "true") {
$("span").text("Query is Validated...").show();
return true;
$("span").text("Query is Not valid!").show().fadeOut(1000);
return false;


When we enter "true", it will display :

Download Source Code

Click here to see demo


Posted on: August 4, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.


Advertisement null