mirror of
https://gitee.com/fastadminnet/think-captcha.git
synced 2026-07-01 14:02:47 +08:00
Merge pull request #26 from cw1997/master
修正了模版拼接错误的BUG,应该将element变量拼接到img标签的id属性,而不是alt属性
This commit is contained in:
@@ -5,9 +5,9 @@ thinkphp5 验证码类库
|
|||||||
> composer require topthink/think-captcha
|
> composer require topthink/think-captcha
|
||||||
|
|
||||||
|
|
||||||
## 使用
|
##使用
|
||||||
|
|
||||||
### 模板里输出验证码
|
###模板里输出验证码
|
||||||
|
|
||||||
~~~
|
~~~
|
||||||
<div>{:captcha_img()}</div>
|
<div>{:captcha_img()}</div>
|
||||||
@@ -18,11 +18,6 @@ thinkphp5 验证码类库
|
|||||||
~~~
|
~~~
|
||||||
> 上面两种的最终效果是一样的
|
> 上面两种的最终效果是一样的
|
||||||
|
|
||||||
或者带有点击图片自动更换验证码的功能
|
|
||||||
~~~
|
|
||||||
<div>{:captcha_img_with_replacement()}</div>
|
|
||||||
~~~
|
|
||||||
|
|
||||||
### 控制器里验证
|
### 控制器里验证
|
||||||
使用TP5的内置验证功能即可
|
使用TP5的内置验证功能即可
|
||||||
~~~
|
~~~
|
||||||
|
|||||||
@@ -57,9 +57,8 @@ function captcha_img($id = '')
|
|||||||
*/
|
*/
|
||||||
function captcha_img_with_replacement($id = '', $element = 'think-captcha')
|
function captcha_img_with_replacement($id = '', $element = 'think-captcha')
|
||||||
{
|
{
|
||||||
return '<img src="' . captcha_src($id) . '" alt="' . $element .
|
return '<img src="' . captcha_src($id) . '" alt="captcha" id="' . $element . '" onclick="document.getElementById("'
|
||||||
'" id="think-captcha" onclick="document.getElementById("' . $element . '").src="' .
|
. $element . '").src="' . captcha_src($id) . '"+Math.random()' . '/>';
|
||||||
captcha_src($id) . '"+Math.random()' . '/>';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user