亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

???? ??


1. ?? ?? ??

<?php
$(document).ready(function() {
    $("#yzmfs").click(function () {
        //確保手機號不為空
        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;
        }
        //點擊發(fā)送短信驗證碼
      
    })
})


2. 60? ?????? js? ?????.

<script type="text/javascript">
    var countdown=60;
    function settime(obj){
        //60秒倒計時
        if (countdown == 0){
            obj.removeAttribute("disabled");
            obj.value="發(fā)送短信驗證碼";
            countdown = 60;
            return;
        }else{
            obj.setAttribute("disabled", true);
            obj.value="重新發(fā)送(" + countdown + ")";
            countdown--;
        }
        setTimeout(function() {
                settime(obj) }
            ,1000)
    }
    </script>

3. Ajax? ???? ??? ??

?? jquery ??? ?????

<script src="jquery-1.11.0.js" type="text/javascript"> </script>

<?php
//點擊發(fā)送短信驗證碼
$.ajax({
    async : false,
    type: "get",
    url: "code.php", //
    data: {},
    success: function (data) {
        $("#code").val(data);
  
    }
});

4, ??? ??? ?? code.php ajax ??? ????

?? ??? ?? base64 ???? ?????. ??? ??? ????.

<?php
$code_len=4;
$code=array_merge(range('A','Z'),range('a','z'),range(1,9));//需要用到的數(shù)字或字母
$keyCode=array_rand($code,$code_len);//真正的驗證碼對應的$code的鍵值
if($code_len==1){
    $keyCode=array($keyCode);
}
shuffle($keyCode);//打亂數(shù)組
$verifyCode="";
foreach ($keyCode as $key){
    $verifyCode.=$code[$key];//真正驗證碼
}
echo base64_encode($verifyCode);


???? ??
||
<?php echo "ajax實現(xiàn)驗證碼的生成";