• gVerify验证码


    1、引入js文件

    2、实现

    <%--
      Created by IntelliJ IDEA.
      User: a
      Date: 2019/8/28
      Time: 10:31
      To change this template use File | Settings | File Templates.
    --%>
    <%@ page contentType="text/html;charset=UTF-8" language="java" %>
    <html>
      <head>
        <title>$Title$</title>
        <script src="js/jquery-1.11.3.js"></script>
        <script src="js/gVerify.js"></script>
      </head>
      <body>
      <!--测试验证码的使用-->
      <center>
        <div id="v_container" style=" 200px;height: 50px;"></div>
        <input type="text" id="code_input" value="" placeholder="请输入验证码"/><button id="my_button">验证</button>
      </center>
      <!--导入js文件-->
      <script>
        //1创建验证码对象
        var verifyCode = new GVerify("v_container");
        //2为按钮绑定一个事件
        document.getElementById("my_button").onclick = function(){
         //3编写单击验证按钮后触发的行为
          //3.1验证输入框中的值与验证码对象中的值是否一致
          var res = verifyCode.validate(document.getElementById("code_input").value);
          if(res){
            alert("验证正确");
          }else{
            alert("验证码错误");
          }
        }
      </script>
    
      </body>
    </html>
  • 相关阅读:
    JS进阶篇--函数防抖(debounce)
    vue注册全局组件分页
    vue下拉框清空
    vue中的watch监听
    五:request和response的使用
    四:servlet最终形态
    三:登录功能实现,servlet
    二:Tomcat与登录
    一:JavaWeb
    Linux安装JAVA并且配置环境
  • 原文地址:https://www.cnblogs.com/qfdy123/p/11426662.html
Copyright © 2020-2023  润新知