Admins eHow SysAdmin Tips & Tricks

July 30, 2009

Disable submit button on click

Filed under: HTML,JavaScript — Tags: , , , , — admin @ 10:50 am

Are you looking for a JavaScript code to disable your HTML form submit button on first click to prevent double clicks ?
so here is the code 🙂 , it has been tested on IE 8 , Firefox 3.5 and Chrome. I am pretty sure it works on all browsers which support JavaScript.
Put the following code into <head> section of your page :

<script language="javascript" type="text/javascript">
function dis(){
frm=document.forms[0];
frm.submit.disabled=true;
}
</script>

and the following code into <form> section :

onsubmit="dis();"

for example :

<form method="post" action="/index.php" onsubmit="dis();">

Powered by WordPress