Jasinski Technical Wiki

Navigation

Home Page
Index
All Pages

Quick Search
»
Advanced Search »

Contributor Links

Create a new Page
Administration
File Management
Login/Logout
Your Profile

Other Wiki Sections

Software

PoweredBy

Disable the Submit Button - jQuery

RSS
Modified on Wed, Jan 19, 2011, 2:15 PM by Administrator Categorized as ASP·NET Web Forms, JavaScript, jQuery, and Angular
The following JavaScript/jQuery code demonstrates how to disable a submit button to avoid double submission. I've verified that this works on an ASP.NET <asp:Button> control only in IE7.

var uxSaveButton  = "span#SaveButton>input";
var uxStatusLabel = "span#StatusLabel>span";

$(document).ready(function() 
{ 
	$(uxSaveButton).click(uxSaveButton_Click);
});
function uxSaveButton_Click()
{
    $(uxStatusLabel).html("Please wait...");
    document.forms[0].submit();
    window.setTimeout("disableButton('" + window.event.srcElement.id + "')", 0);
}
function disableButton(buttonID) 
{
    document.getElementById(buttonID).disabled = true;
}

ScrewTurn Wiki version 3.0.1.400. Some of the icons created by FamFamFam. Except where noted, all contents Copyright © 1999-2024, Patrick Jasinski.