tp5 点击刷新验证码


<form action="<{:url('index/index/login')}>" method="post" name="form1" >


  <input type="text" name="username"><br>
  <input type="text" name="password"><br>
  <input type="text" name="captcha" placeholder="请输入验证码" required=""><br>
  <img src="<{:captcha_src()}>" width="95" height="45" onclick="this.src='<{:captcha_src()}>'"><br><br>


  <input type="submit"><br>

</form>

-----------------------------------------------------------------------------------------------------

$captcha = $_REQUEST['captcha'];

if(!captcha_check($captcha)){
  //验证失败
  $this->error('验证码输入错误');
}else{

  $this->success('验证码输入正确');

}

 

 

================================================

JS触发事件,提交后刷新验证码

<img src="<{:captcha_src()}>" id="verify_img" width="95" height="45" onclick="this.src='<{:captcha_src()}>'">
var img = document.getElementById('verify_img');
img.src = "<{:captcha_src()}>";
================================================


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM