This Page Will Show You How To Hide A Submit Button In A Html Web Form Using Javascript To Hide And Show When User Click On The Submit Button And Send The Information But Hides The Button And Shows A Text Instead Like Please Wait [2200], Last Updated: Mon Jun 24, 2024
Webune Tutorials
Tue Dec 29, 2009
2 Comments
529 Visits
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
yuin
Tue Aug 02, 2011
i almost tried it, but i needed to enable javascript
https://www.webune.com/forums/how-to-hide-button-onsubmit-javascript.html