Js controls the time between clicking the button again to prevent duplicate submissions
- 2020-03-30 03:40:06
- OfStack
<script type="text/javascript" language="javascript">
var wait = 60;
function change() {
$o = $("#J_refresh_checkcode");
if(wait == 0) {
$o.removeAttr("disabled");
$o.html(" Can't see? In a ");
wait = 60;
} else {
$o.attr("disabled", true);
$o.attr("font-color", "gray");
$o.html(wait + " Can be retrieved after seconds ");
wait--;
if(wait == 59) {
var imgNode = document.getElementById("vimg");
imgNode.src = "../../AjaxServer/CheckCodePic.ashx?t=" + (new Date()).valueOf(); //The time parameter is added to prevent browser caching problems
$("#J_checkcode_tip").addClass("hide");
$("#J_checkcode_tip>div").html("");
$("#<%=hidPicMessage.ClientID%>").val("");
}
setTimeout(function() {
change()
},
1000)
}
}</script>
Then the HTML is as follows:
<div class="kv_item clear">
<span class="kv_label fl"> Verification code </span>
<input name="checkCode" class="i_textshort fl" id="J_checkcode_input" onmousedown="ClearCodeMessage()" type="text" maxlength="6" autocomplete="off" onblur="CheckCode()" />
<img src="../../AjaxServer/CheckCodePic.ashx" height="28" id="vimg" alt="" style="float:left;margin:-1px 0 0 3px"/>
<a id="J_refresh_checkcode" onclick="change()"> I can't see it. Switch </a>
<div class="msg msg-inline msg-weak hide" id="J_checkcode_tip">
<div class="msg-default msg-error">
<i class="msg-icon"></i>
<div class="msg-content">
</div>
</div>
</div>
</div>