Aspdotnet-Suresh

aspdotnet-suresh offers C#.net articles and tutorials,csharp dot net,asp.net articles and tutorials,VB.NET Articles,Gridview articles,code examples of asp.net 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

jQuery Disable Submit Button After Click to Avoid Duplicate Form Submission

Jul 27, 2013
Introduction

Here I will explain how to use
jQuery to disable submit button after first click to avoid duplicate or multiple form submission or jQuery disable submit button after click to avoid duplicate form submission.

Description:
  
In previous articles I explained
jQuery Get Current Datetime, Auto refresh page , Expand textbox on focusDisable right click on image and many articles relating to jQuery. Now I will explain how to disable submit button after click to avoid multiple form submission using jQuery.

Disable a button after click


$('#btnClick').click(function() {
$(this).attr("disabled", true);
$(this).val('Please wait Processing');
// Write your Code
$(this).attr("disabled", false);
$(this).val('Submit');

})
If you want to see it in complete example write the code like as shown below


<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>jQuery Disable Submit Button to avoid multiple times form submission Page</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script type="text/javascript">
$(function() {
$('#btnClick').click(function() {
$(this).attr("disabled", true);
$(this).val('Please wait Processing');
// Write your Code
})
$('#btnReset').click(function() {
$('#btnClick').attr("disabled", false);
$('#btnClick').val('Click');
})
})
</script>
</head>
<body>
<div>
<input type="button" id="btnClick" value="Click" />
<input type="button" id="btnReset" value="Reset" />
</div>
</body>
</html>
Demo





If you enjoyed this post, please support the blog below. It's FREE!

Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email

4 comments :

sanju said...

Very Nice...

Anonymous said...

Just a question. What will happen, if the page is refreshed instead of clicking the button? Don't you think redirecting the page is wise decision.

Unknown said...

how to create progress bar in jquery

OfferPerk said...

The Form is not submitting while i use document.getElementById("demo").disabled = "true"; Why?
How to acheive that?

Give your Valuable Comments

Note: Only a member of this blog may post a comment.

© 2015 Aspdotnet-Suresh.com. All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.