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

Page History: Disable the Submit Button - jQuery

Compare Page Revisions



« Older Revision - Back to Page History - Current Revision


Page Revision: Tue, Sep 15, 2009, 3:18 PM


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.