求js高手,给短信验证码js添加一个倒计时功能

JavaScript014

求js高手,给短信验证码js添加一个倒计时功能,第1张

<!DOCTYPE HTML>

<html>

<head>

<meta charset="UTF-8" />

<title>pro.html</title>

<style type="text/css">

.checkCode {

    cursor: pointer

    border: 1px solid black

    text-align: center

    line-height: 26px

    width: 115px

    height: 35px

}

</style>

<script type="text/javascript">

    var sleep = 30, interval = null

    window.onload = function ()

    {

        var btn = document.getElementById ('btn')

        btn.onclick = function ()

        {

            if (!interval)

            {

                this.style.backgroundColor = 'rgb(243, 182, 182)'

                this.disabled = "disabled"

                this.style.cursor = "wait"

                this.value = "重新发送 (" + sleep-- + ")"

                interval = setInterval (function ()

                {

                    if (sleep == 0)

                    {

                        if (!!interval)

                        {

                            clearInterval (interval)

                            interval = null

                            sleep = 30

                            btn.style.cursor = "pointer"

                            btn.removeAttribute ('disabled')

                            btn.value = "免费获取验证码"

                            btn.style.backgroundColor = ''

                        }

                        return false

                    }

                    btn.value = "重新发送 (" + sleep-- + ")"

                }, 1000)

            }

        }

    }

</script>

</head>

<body>

    <input class="checkCode" type="button" id="btn" value="免费获取验证码" />

</body>

</html>

登入dedecms的后台,选择系统 ->会员设置 ->在是否开启会员功能选择“是”。保存。

在 系统 ->sql命令行工具 –>多行命令 –>填写sql语句(附件文件member.sql记事本打开,复制过来) –>确认执行。把需要的创建的信息写入数据库中。

系统 ->系统基本参数 ->其它选项,填写你的短信精灵用户名,密码以及短信签名,确定保存。

把插件中的member目录覆盖到项目目录下。开始到网站前台,注册用户名,测试短信功能。