jQuery to disable submit button to prevent duplicate postback

Well, it is quite possible that user may click the submit button more than once to post the data. Which in turn may lead to duplicate postback. And it may create problems like duplicate insertion of records, if not handled properly. So it is preferable to disabled the submit button once it is clicked so that duplicate postback can be prevented.

We can handle this at 2 different places. One is on form submit event and second is when button is clicked.

jQuery code to handle on form submit event.
$("form").submit(function() {
    $("#btnSubmit").attr("disabled", "disabled");
jQuery code to handle on submit button click event.
$("#btnSubmit").click(function() {
    $(this).attr("disabled", "disabled");
Feel free to contact me for any help related to jQuery, I will gladly help you.

Nothing shocks me, I'm a Software Engineer. And I am not young enough to know everything. I live in World Wide Web and from there take care of this website. This website communicates about my work, learning and experience. I believe life is short, and it is for loving, sharing, learning and connecting. So lets connect..