Home > Web Front-end > JS Tutorial > body text

Detailed explanation of how JavaScript disables the submit button after form submission

黄舟
Release: 2017-07-22 14:04:42
Original
3293 people have browsed it

This article mainly introduces the method of javascript to make the submit button unavailable after the form is submitted. It involves the techniques of dynamically modifying the form style with javascript. It is very simple and practical. Friends in need can refer to the following

Examples of this article Use javascript to implement a method to make the submit button unavailable after the form is submitted. Share it with everyone for your reference. The details are as follows:

After using javascript to control the form submission, the submit button is unavailable, which can prevent users from submitting multiple times.


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>表单提交后按钮禁用</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="提交表单"
 onclick="return sub();" />
  </form>
</body>
</html>
Copy after login

The above is the detailed content of Detailed explanation of how JavaScript disables the submit button after form submission. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template