Welcome to Webune Web Hosting Forums.

Webune provides Web hosting for your domains. Sign up and benefit from all of our free tutorials like this one.

Today we will show you how you can use javascript to disable a button once it has been clicked by a user.

for example, lets say you have a form, and once the user has submitted the form, you want to show a message the says: please wait...

well, you are in luck, because today we are going to show you how to disable the button using javascript OnSubmit() function




DEMO: Try it! - Click on the Submit button below, you will see that once you click on the submit button, the button will become disabled and you cannot click again.






COOL!! - as you can see, this trick will prevent your users from submitting a form twice. this is very helpful in situation where you have a contact us form and you get multiple submits, this will help avoid multiple submits and you wont get repeated information or content on your forums or blogs.

so how did i do this. below is the code i use to demonstrate this tutorial:

<script type="text/javascript" language="javascript">
   /* SCRIPT CREATED BY WWW.WEBUNE.COM - WEBUNE WEB HOSTING */
   // Find more usefull scripts at http://www.webune.com
   function HideButton(hide){
		if(hide){
			document.getElementById('FormButton').disabled = true;
			document.getElementById('FormButton').value = "Please Wait";
		}
	 }
</script>


please try it on your browser, and tell us what type of browser you are using and if it worked for you

thanks