CODEDIGEST
Home » CodeDigest
Search
 

Technologies
 

Disable Submit Button after First Click to Prevent Duplicate Postback Using jQuery in Asp.Net
Submitted By Bala Murugan
On 9/7/2009 8:49:29 AM
Tags: CodeDigest,jQuery  

Disable Submit Button after First Click to Prevent Duplicate Postback Using jQuery in Asp.Net

 

Sometimes, there are chances that the user may click the submit button more than once to post the data. It will be good if we disable the submit button after user clicks for the first time to prevent the duplicate postbacks. This will lead to some serious consequences like duplicate data insertion, etc when not handled properly. This can be handled many ways, like checking in server side for duplicate data insertions, etc. In this little code snippet, we will disable the submit button once the user clicks the submit button so that it is not clicked again.

 

The following jQuery code will help us to do that,

  <script src="_scripts/jquery-1.3.2.min.js" type="text/javascript"></script>    

    <script language="javascript">

        $("form").submit(function() {

            $(":submit", this).attr("disabled", "disabled");

          });

</script>

 

In the above code, we are setting the disable attribute once the submit is clicked which will prevent the multiple page submission.

Do you have a working code that can be used by anyone? Submit it here. It may help someone in the community!!

Recent Codes
  • View All Codes..