直播平臺原始碼,簡訊驗證碼傳送demo

zhibo系統開發 發表於 2022-11-24

直播平臺原始碼,簡訊驗證碼傳送demo

<?php
?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="
    <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,更多內容歡迎關注之後的文章


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/69978258/viewspace-2924941/,如需轉載,請註明出處,否則將追究法律責任。