Skip To Main Content | Home | Sitemap | Contact
Latest Visitors: United States's flagUnited States's flagUnited States's flagUnited States's flagUnited States's flagKorea  Republic of's flagUnited States's flagRussian Federation's flagChina's flagSweden's flagNetherlands's flagUnited States's flagUnited States's flagChina's flagChina's flagPakistan's flagUnited States's flagUnited States's flagUnited States's flagSpain's flagUnited States's flagUnited States's flagUnited States's flagUnited States's flagUnited States's flag
 

How can you disable the submit button so the form only gets submitted once?

Really you can not completely disable the form, but you can stop the accidental resubmission if the user's browser has JavaScript enabled.  This example will also disable the radio buttons as some people ask how to disable form fields as well as the submit button.  This will not interfere with form submission, just minimize the chance of a double click.  [Better way - Cross Browser]

  Yes  No

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="author" content="Roderick Divilbiss">
<meta name="copyright" content="© 2005-2010 Roderick Divilbiss">
<script type="text/javascript">
<!--
function spButtonClick() {
  document.getElementById('R1a').disabled=true;
  document.getElementById('R1b').disabled=true;
  document.getElementById('B1').value=' Please Wait... ';
  document.getElementById('B1').disabled=true;

}
//-->
</script>
<title>rodsdot.com :: disable the submit button on form submit</title>
</head>

<body>
<script type="text/javascript">
  document.write('<input type="button" value="Submit and Disable" name="B1" onclick="spButtonClick();">');
</script>
<noscript>
  <input type="button" value="Submit (Can't Disable)" name="B1">
</noscript>
<input id="R1a" type="radio" value="1" name="R1" checked>&nbsp;Yes
<input id="R1b" type="radio" value="2" name="R1">&nbsp;No
</body>

</html>


This Weeks Most Popular Pages Newest Pages