Members

Technology Zones

IBM Learning Center

Articles

Hosted By

MaximumASP

Info

Rated
Read 13,842 times

Related Categories

How to disable all elements on a form

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>

Edward Tanguay updates his personal web site tanguay.info weekly with code, links, quotes and thoughts on web development. Sign up for the free newsletter.

Comments