thinkphp中验证码完成方法

对于在thinkphp框架当中引入登录页面后如何在存在的框架中实现验证码不断刷新功能:

1.实现tp5.0框架当中自带的验证码功能:

1.1thinkphp5.0已内置验证码,只需直接在模板文件添加

{:captcha_src()}

详细手册:https://www.kancloud.cn/manual/thinkphp5/154295

1.2实现验证码看不清,换一张的解决方案需要如下技术:

            <div class="row cl">
                <div class="formControls col-xs-8 col-xs-offset-3">
                    <input name="verify" class="input-text size-L" type="text" placeholder="验证码" onblur="if(this.value==''){this.value='验证码:'}" onclick="if(this.value=='验证码:'){this.value='';}" value="验证码:" style="width:150px;">
                    <img id="verity_img" src="{:captcha_src()}" />
                    <a id="kanbuq" href="javascript:refreshVerity();">看不清,换一张</a>
                </div>
            </div>

例如我们需要实现验证码的刷新技术:

<script>
//刷新验证码的脚本
function refreshVerity(){
    var ts=Date.parse(new Date())/1000;
    $("#verity_img").attr("src","/captcha?id="+ts);//刷新验证码
}
</script>

知识剖析:

1.实现验证码功能所需要的thinkphp当中中杂项的知识

2.jquery中知识点:

详细知识点:

jquery中的attr函数:

https://www.runoob.com/jquery/html-attr.html

data中的parse方法阅读博客:

https://blog.csdn.net/wxl1555/article/details/63683775

 

posted @ 2020-10-01 21:56  小高家的小胖子  阅读(204)  评论(0编辑  收藏  举报