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