驗證碼的輸入框及圖片代碼:【使用tp5的驗證碼】
<!-- 驗證碼輸入框及圖片 -->
<div class="form-group">
<div class="row">
<!-- /.col -->
<div class="col-xs-5">
<input type="text" class="form-control" name="captcha" maxlength="4" onkeyup="value=value.replace(/[^\w\.\/]/ig,'')" placeholder="驗證碼" required>
</div>
<div class="col-xs-7">
<img onclick="this.src='{:captcha_src()}?'+Math.random()" id="captcha" src="{:captcha_src()}" alt="captcha"/>
</div>
<!-- /.col -->
</div>
</div>
js代碼:
$.ajax({
url:'login',
type:'post',
data:form,
success:function (data) {
if (data.status == 0) {
window.location.href = '/AuthBase.Index/index';
} else {
layer.msg(data.msg);
//刷新驗證碼
$("#captcha").attr("src","{:captcha_src()}?"+Math.random())
//定時器
isClick(data.data);
}
},
error:function (error) {
layer.msg(error);
isClick();
}
},'json');