How to prevent repeated form submission in JS

Write the following code in the login page html

<script type="text/javascript">
        var issubmit=false;
        function dosubmit(){
            if(issubmit==false){
                issubmit=true;
                return true;
            }else{
                return false;
            }
            
        }
    </script>
  </head>
  
  <body>
      <form action="/Day07/FormSubmit" method="get" onsubmit="return dosubmit()">
          用户名:<input type="text" name="usrname">
          <br><input type="submit" value="提交">
      </form>
  </body>

The point is that this JS statement defines a method to share a Flag tag for verification. If it has been submitted, it will return a false to onsubmit the data

If it has not been submitted, set the flag to true and return a ture to onsubmit to let it submit data once. This is js to prevent repeated submission of the form. The response is to transmit data

The problem caused by the network delay and the user submitting data multiple times

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325160867&siteId=291194637