我遇到过无法抗拒两次、三次或多次点击的人的问题。这可能会给您带来各种问题。这就是我使用 Jquery 解决多次提交的方法。如果对您有帮助,请随意复制。复制粘贴进行测试。如果你愿意,可以疯狂地点击。此表格只提交一次!
<%@LANGUAGE="VBSCRIPT"%>
<%Option Explicit%>
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<style type="text/css">
body{
height:100%;
width:100%;
}
h2 {
font-family:sans-serif;
font-style:italic;
font-size:1.4em;
color:#777;
}
#tekst {
padding:6px;
border:none;
border-radius:4px;
background-color:#666;
color:#fff;
opacity:1;
}
.loading {
opacity:0.7;
background-color:#ddd;
position:fixed;
width:100%;
height:100%;
top:0px;
left:0px;
z-index:1 /*(top)*/;
visibility:hidden
}
.loading-content {
width: 240px; /* or to your liking.*/
height: 100px;
text-align:center;
margin: 0 auto;
padding-top:25px;
position: relative;
top:20%;
background-color:#900;
font-size:1.1em;
font-weight:bold;
font-style:italic;
font-family:sans-serif;
color:#eee;
opacity:1;
z-index:2; /*above . loading*/
user-select: none; /* Non-prefixed version, currently
supported by Chrome, Edge, Opera and Firefox */
}
#upload {
background-color:#000;
color:#fff;
font-style:italic;
font-weight:bold;
border-radius:8px;
border-color:#000;
padding:3px 8px;
cursor:pointer;
z-index:-1;
}
p {
display:inline-block;
font-size:1em;
font-style:italic;
color:#555;
}
br {
line-height:40px;
}
</style>
<title>test</title>
</head>
<body>
<%
'this is VB script, but use whatever language you want to receive the submitted form
dim tekst
tekst=Request.Form("tekst")
if tekst <> "" then
Response.Write("<h2>" & tekst & " (Submitted only once).</h2>")
end if
%>
<div class="loading">
<div class="loading-content"></div>
</div>
<form action="#" method="post" id="form1">
<input type="text" name="tekst" id="tekst" placeholder="Enter some text"/>
<input type="submit" value="Submit form" Id="upload" /> <p>Try and double or triple click to check, also during submit.</p>
</form>
<script type="text/javascript">
$(function () {
$(":submit").on('click', function (e) { //this happens when you click, doubleclick or whatever how many clicks you do:
e.preventDefault(); //first we prevent a submit to happen
$(':submit').attr('disabled', 'disabled'); // then disable the submit button
$('.loading').css('visibility', 'visible'); //now the page load message is made visible
$('.loading-content').html("Page is loading.<br>Please wait a second.");
$('.loading').fadeOut(3000); // you do this your own way of course
setTimeout(function () { $('#form1').submit();}, 2000); //Here is the important clue. Now, submit the form, with or without a message . Because of the delay, doubleclicks are filtered out and the form submits only once.
});
});
</script>
</body>
</html>