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 focus, Disable 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.
In previous articles I explained jQuery Get Current Datetime, Auto refresh page , Expand textbox on focus, Disable 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. |
|||
|
|||
4 comments :
Very Nice...
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.
how to create progress bar in jquery
The Form is not submitting while i use document.getElementById("demo").disabled = "true"; Why?
How to acheive that?
Note: Only a member of this blog may post a comment.