caphyyy

  为了实现前端的图片验证码验证,借用了gVerify.js

  效果:

 

  1.先在页面插入一个验证码图片的容器,宽高等样式可以自己设置。

<div id="v_container" style="width: xxxpx;height: xxxpx;"></div>
<input type="text" id="code_input" value="" placeholder="请输入验证码"/>

  2.引入gVerify.js

<script src="xxx/gVerify.js"></script>

  3.初始化验证码图片

var verifyCode = new GVerify("v_container");

  4.初始化之后就可以在js内判断input中输入的验证码和生成的图片验证码是否相同

var res = verifyCode.validate(document.getElementById("code_input").value);
if(res){
    alert("验证正确");
}else{
    alert("验证码错误");
}

 

分类:

技术点:

相关文章:

  • 2021-10-29
  • 2021-07-08
  • 2021-08-07
  • 2021-11-07
  • 2021-08-07
  • 2021-09-15
  • 2021-06-28
猜你喜欢
  • 2021-10-03
  • 2021-11-28
  • 2021-06-19
  • 2021-11-27
  • 2022-01-06
  • 2021-09-08
相关资源
相似解决方案