直播平台源代码,短信验证码发送demo

直播平台源代码,短信验证码发送demo

 

<?php
?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="http://code.jquery.com/jquery-1.11.2.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        var countdown=60;
        function settime(obj){
            //60秒倒计时
 if (countdown == 0){
                obj.removeAttribute("disabled");
                obj.value="发送短信验证码";
                countdown = 60;
                return;
            }else{
                obj.setAttribute("disabled", true);
                obj.value="重新发送(" + countdown + ")";
                countdown--;
            }
            setTimeout(function() {
                    settime(obj) }
                ,1000)
        }
        $(document).ready(function() {
            
            $("#yzmfs").click(function () {
            var randomnum=Math.floor(Math.random()*(9999-1000))+1000;
                //确保手机号不为空
 var mobile=$("#phone").val();
                if(mobile.length==0)
                {
                    alert('请输入手机号码!');
                    $("#phone").focus();
                    return false;
                }
                if(mobile.length!=11)
                {
                    alert('请输入11位手机号!');
                    $("#phone").focus();
                    return false;
                }
                var myreg = /^((1[3|4|5|8][0-9]{1})+\d{8})$/;
                if(!myreg.test(mobile))
                {
                    alert('请输入正确的手机号码!');
                    document.getElementById("phone").focus();
                    return false;
                }
                //点击发送短信验证码
 $.ajax({
                    async : false,
                    type: "post",
                    url: "code.php", //
 data: {"yzm": randomnum, 'yzmtel': $('#phone').val()},
                    success: function (data) {
                        //发送短信验证码
                           if(data=='Ok'){
                               
                                
                                $('#msg').val(randomnum);
                           }
                    }
                });
            })
           
        })
        function reg(){
                 var yzm=$("#yzm").val();
                 //alert(yzm);
                if(yzm.length==0)
                {
                    alert('请输入验证码!');
                    $("#yzm").focus();
                    return false;
                }
                if($("#yzm").val() != $("#msg").val()){
                     alert('验证码不正确!');
                    $("#yzm").focus();
                    return false;
                }
                return true;
         }
    </script>
</head>
<body>
<form action="check.php" method="post" onsubmit="return reg()">
    用户名:<input type="text" id="name" name="name"/><br>
    密码:<input type="password" id="pwd" name="pwd" /><br>
    手机号:<input type="text" id="phone" name="phone" /><br>
    
    <input id="msg" hidden name='msg'>
    <input type="text" id="yzm" name="yzm"><input type="button" id="yzmfs" value="发送短信验证码" onclick="settime(this)" /> <br>
    <input type="submit" id='register' name='register' value="注册" >
</form>
</body>
</html>

以上就是 直播平台源代码,短信验证码发送demo,更多内容欢迎关注之后的文章

 

posted @ 2022-11-24 14:10  云豹科技-苏凌霄  阅读(32)  评论(0)    收藏  举报