Library code snippets
How to disable all elements on a form
By Edward Tanguay, published on 11 Jan 2006
You can have your form to be disabled as soon as the user pressed the submit button so that he doesn't accidently submit the form twice. This is the code you can use.
<HTML>
<HEAD>
<script>
function disableForm(theform) {
if (document.all || document.getElementById) {
for (i = 0; i < theform.length; i++) {
var formElement = theform.elements[i];
if (true) {
formElement.disabled = true;
}
}
}
}
</script>
</HEAD>
<BODY>
<form method="post" action="http://www.sdfsdf.com" onSubmit="return disableForm(this);">
<input type="text" name="Text1">
<input type="submit" name="SubmitButton" value="Submit">
</form>
</BODY>
</HTML>
Related articles
Related discussion
-
An old chestnut: Scrolling DIVs. Can I use onmouseover/onmouseout?
by Skunk (1 replies)
-
code highlighting using jquery
by pjm (1 replies)
-
Problem when using TemplateField and ImageButton
by mhuff84 (14 replies)
-
dropdownlist for country,state and city
by jack_tom (2 replies)
-
popup window in vb.net... how it's work?..
by yf2009 (6 replies)
Related podcasts
-
jQuery in ASP.NET
In this episode Chris Brandsma, Rick Strahl, Dave Ward, Bertrand Le Roy, Scott Koon, and Steven Harman discuss Microsoft's jQuery in ASP.NET announcement.This episode of the Alt.NET Podcast is brought to you by LLBLGen Pro, the most mature O/R mapper and code generator out there.Are you loo...
Events coming up
-
Oct
28
Web Standards Group (Sydney)
North Sydney, Australia
TBA
This thread is for discussions of How to disable all elements on a form.