javascript implements a method that makes the submit button unavailable after the form is submitted

  • 2020-06-01 08:10:51
  • OfStack

This article illustrates how the submit button is not available after javascript implements a form submission. Share with you for your reference. The details are as follows:

When javascript is used here to control form submission, the submit button becomes unavailable, preventing the user from submitting multiple times.


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title> The button is disabled after the form is submitted </title>
<script type="text/javascript">
function sub() {
  document.forms[0].elements[0].disabled = true;
  document.forms[0].submit();
}
</script>
</head>
<body>
  <form action="login.action" method="post">
    <input type="button" name="btn" value=" Submit the form "
 onclick="return sub();" />
  </form>
</body>
</html>

I hope this article is helpful for you to design javascript program.


Related articles: