js验证码倒计时

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>验证码的倒计时</title>
    <style type="text/css">
        *{ margin: 0; padding: 0}
        #btn{
                background: #fff;
                border-radius: 20%;
                text-align: center;
                font-size: 18px;
                font-weight: bold;
                color: #fff;
                margin: 100px auto;
                height: 50px;
                width: 150px;
                color: #000;
            }
        #btn.set {
            background: #666;
            color: #fff;
        }
    </style>
</head>
<body>
<input type="button" id="btn" value="免费获取验证码" />
<script type="text/javascript">
var wait=12;
function time(o) {
    if (wait == 0) {
        o.removeAttribute("disabled");
        o.className = "";
        o.value="免费获取验证码";
        wait = 12;
    }
    else {
        if(wait<10){
            o.value="重新发送(0"+wait+")";
            wait--;
            setTimeout(function() {
                time(o)
            },1000)
        }
        else{
            o.setAttribute("disabled", true);
            o.className = "set";
            o.value="重新发送(" + wait + ")";
            wait--;
            setTimeout(function() {
                time(o)
            },1000)
        }
    }
}
document.getElementById("btn").onclick=function(){
    time(this);
}
</script>
</body>
</html>

发送验证码倒计时效果

时间: 2024-10-10 01:54:04

js验证码倒计时的相关文章

js 验证码 倒计时60秒

<input type="button" id="btn" value="免费获取验证码" /> <script type="text/javascript"> var wait=60; function time(o) { if (wait == 0) { o.removeAttribute("disabled"); o.value="免费获取验证码"; wai

js 验证码倒计时效果

function settime(obj) { if(second == 0){ obj.removeAttribute("disabled"); obj.value="获取验证码"; second = 300; return; }else{ obj.setAttribute("disabled", true); obj.value="重新发送(" + second + ")"; second--; } t

js 发送验证码倒计时

<input  type="text"   name=''  id="btn"> //发送验证码倒计时var wait=30; function time(o) { if (wait == 0) { o.removeAttribute("disabled"); o.value="免费获取验证码"; wait = 30; }else{ o.setAttribute("disabled", true

60秒验证码倒计时js代码 js样式代码 方块上下左右随机移动(定时器) js中获取元素的方法 js中表单提交

60秒验证码倒计时js代码 <script type="text/javascript"> var countdown=60; function settime(val) { if (countdown == 0) { //removeAttribute() 方法删除指定的属性. disabled属性规定应该禁用 input 元素. val.removeAttribute("disabled"); val.value="免费获取验证码"

js点击按钮获取验证码倒计时

//发送验证码倒计时 var clock = ''; var nums = 60; var btn; $("#btnGetVerCode").click(function () { var flag = true; var phoneNum = $("#txtPhoneNum").val(); if (phoneNum.length == 11 && /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1})|(14[0-9

js 发送短信验证码倒计时

html <input type="button" id="btn" value="免费获取验证码" onclick="settime(this)" /> js // 短信验证码倒计时var countdown=60;function settime(obj) { if (countdown == 0) { obj.removeAttribute("disabled"); obj.value=&

验证码倒计时js

getVarify.js // 验证码计时--第一种 window.onload = function () { var send = document.getElementById('send'), //按钮ID times = 10, // 别忘了改这里 timer = null; send.onclick = function () { // 计时开始 send.disabled = true; timer = setInterval(function () { times--; if (

短信验证码倒计时

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="yan.aspx.cs" Inherits="Technology.yan" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"><head runat="server&

js实现倒计时60秒的简单代码(推荐)

<!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>js实现倒计时60秒的简单代码(推荐)</title> <script type="text/javascript"