This article describes the method of implementing the countdown of user registration protocol by JS. Share it for your reference. The specific implementation method is as follows:
The code copy is as follows: <html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Register</title>
<script type="text/javascript">
//The user has ten seconds to view the agreement. If it takes more than ten seconds, the "Agree" button will take effect
var Seconds = 10;
//Timer ID
var setIntervalID;
function ok() {
var getid = document.getElementById("but");
if (Seconds <= 0) {
getid.value="Agree";
getid.disabled = false; //or write getid.disabled=""; Enable getid control.
//Stop the timer
clearInterval(setIntervalID);
}
else {
getid.value = "Please read carefully the protocol and there are still [" + Seconds + "] seconds";
}
Seconds--;
}
setIntervalID=setInterval("ok()", 1000);
</script>
</head>
<body>
<textarea cols="20" rows="8"></textarea><br />
<!--disabled="disabled" The default submit form is disabled, that is, read-only, and cannot be clicked-->
<input type="submit" id ="but" value="Agree" disabled="disabled" />
</body>
</html>
I hope this article will be helpful to everyone's JavaScript programming.