Home > Web Front-end > JS Tutorial > How to use javascript to make the submit button unavailable after form submission_javascript skills

How to use javascript to make the submit button unavailable after form submission_javascript skills

WBOY
Release: 2016-05-16 16:03:02
Original
1422 people have browsed it

The example in this article describes how to use JavaScript to make the submit button unavailable after the form is submitted. Share it with everyone for your reference. The details are as follows:

Here, JavaScript is used to control the submit button to be unavailable after form submission, which prevents 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

I hope this article will be helpful to everyone’s JavaScript programming design.

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