网络编程 
首页 > 网络编程 > 浏览文章

js登录滑动验证的实现(不滑动无法登陆)

(编辑:jimmy 日期: 2024/11/8 浏览:3 次 )

js的判断这里是根据滑块的位置进行判断,应该是用一个flag判断

<%@ page language="java" contentType="text/html; charset=utf-8"
 pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
 String basePath = request.getContextPath();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>登录</title>
<link href="<%=basePath%>/res/css/bootstrap.min14ed.css" rel="external nofollow" 
 rel="stylesheet">
<link href="<%=basePath%>/res/css/font-awesome.min93e3.css" rel="external nofollow" 
 rel="stylesheet">
<link href="<%=basePath%>/res/css/animate.min.css" rel="external nofollow" rel="stylesheet">
<link href="<%=basePath%>/res/css/style.min862f.css" rel="external nofollow" 
 rel="stylesheet">
<!--[if lt IE 9]>
 <meta http-equiv="refresh" content="0;ie.html" />
 <![endif]-->
<script>
 if (window.top !== window.self) {
 window.top.location = window.location;
 }
</script>
<style>
* {
 margin: 0;
 padding: 0;
}
body {
 font: 12px/1.125 Microsoft YaHei;
 background: #fff;
}
ul, li {
 list-style: none;
}
a {
 text-decoration: none;
}
.ani {
 transition: all .3s;
}
.wrap {
 width: 300px;
 height:;
 text-align: center;
 margin: 150px auto;
}
.inner {
 padding: 15px;
}
.clearfix {
 overflow: hidden;
 _zoom: 1;
}
.none {
 display: none;
}
#slider {
 position: relative;
 background-color: #e8e8e8;
 width: 300px;
 height: 34px;
 line-height: 34px;
 text-align: center;
}
#slider .handler {
 position: absolute;
 top: 0px;
 left: 0px;
 width: 40px;
 height: 32px;
 border: 1px solid #ccc;
 cursor: move;
}
.handler_bg {
 background: #fff
 url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2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AY9mEFgMMgBk00E0iZtA7AHEctDQ58MRuA6wlLgGFMoMpIG1QFeGwAIxGZo8GUhIysmwQGSAZgwHaEZhICIzOaBkJkqyM0CAAQDGx279Jf50AAAAAABJRU5ErkJggg==")
 no-repeat center;
}
#slider .drag_bg {
 background-color: #7ac23c;
 height: 34px;
 width: 0px;
}
#slider .drag_text {
 position: absolute;
 top: 0px;
 width: 300px;
 -moz-user-select: none;
 -webkit-user-select: none;
 user-select: none;
 -o-user-select: none;
 -ms-user-select: none;
}
.unselect {
 -moz-user-select: none;
 -webkit-user-select: none;
 -ms-user-select: none;
}
.slide_ok {
 color: #fff;
}
</style>
</head>
<style>
.btn-primary {
 background-color: #0000FF;
}
.btn-primary:hover {
 background-color: #0000FF;
}
.btn-primary {
 background-color: #0000FF;
 border-color: #0000FF;
}
</style>
<body class="gray-bg">
 <div class="middle-box text-center loginscreen animated fadeInDown">
 <div>
  <h3 style="margin-top: 100px;">欢迎登录</h3>
  <form class="m-t" role="form" action="<%=basePath%>/login"
  method="POST" onsubmit="return login();">
  <div class="form-group">
   <input name="username" id="username" type="text"
   class="form-control" placeholder="用户名" required="">
  </div>
  <div class="form-group">
   <input type="password" name="password" id="password"
   class="form-control" placeholder="密码" required="">
  </div>
  
  <div class="wrap" style="margin: 10px auto 10px">
   <div id="slider">
   <div class="drag_bg"></div>
   <div class="drag_text" onselectstart="return false;"
    unselectable="on">拖动滑块验证</div>
   <div class="handler handler_bg"></div>
   </div>
  </div>
  <input type="hidden" name="${_csrf.parameterName}"
   value="${_csrf.token}">
  <button type="submit" style="background-color: #0000FF;" class="btn btn-primary block full-width m-b">登
   录</button>
  <%
   if (request.getParameter("error") != null) {
  %>
  <span id="" style="color: red;">账号或者密码错误!</span>
  <%
   }
  %>
  <%
   if (request.getParameter("logout") != null) {
  %>
  <span>已经安全退出!</span>
  <%
   }
  %>
  <p class="text-muted text-center">
   <a href="login.html#" rel="external nofollow" ><small>忘记密码了?</small></a> | <a
   href="<%=basePath%>/register" rel="external nofollow" >注册一个新账号</a>
  </p>
  </form>
 </div>
 </div>
 <script src="/UploadFiles/2021-04-02/jquery.min.js">

以上这篇js登录滑动验证的实现(不滑动无法登陆)就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。

上一篇:js判断文件类型大小并给出提示的实现方法
下一篇:Angular实现下拉框模糊查询功能示例
友情链接:杰晶网络 DDR爱好者之家 南强小屋 黑松山资源网 白云城资源网 网站地图 SiteMap