注册
功能(短信验证,MD5加密,滑块验证)
注册页面
<%--
@User Zhoudalf
@Create 2022-04-30 10:26
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<html>
<head>
<title>Title</title>
<link rel="stylesheet" href="static/css/range.css" />
<script type="text/javascript" src="static/js/jquery-3.6.0.min.js"></script>
</head>
<body>
<%application.setAttribute("ss","dsd");%>
<div id="container" style="width: 550px; margin: 20px auto">
<div id="header" style="font-size: 25px;
text-align: center;
margin-bottom: 10px;">注册中心</div>
<form action="${pageContext.request.contextPath}/register" method="post" autocomplete="off">
<div >
<div>
<input type="text" id="phone" name="phone" placeholder="请输入手机号码">
</div>
</div>
<div >
<input type="text" name="securityCode" placeholder="请输入验证码">
</div>
<div><label><span>密码:</span><input type="text" name="pw" placeholder="请输入8到20位数字+字母的密码"/></label></div>
<button id="registerBtn">注册</button>
</form>
<div style="justify-content:flex-end;display: flex;">
<button type="button" id="send">点击获取验证码</button>
</div>
</div>
<%--滑块--%>
<div class="container">
<div id="captcha" style="position: relative">
</div>
</div>
<script type="text/javascript">
(function(window) {
const l = 42, // 滑块边长
r = 10, // 滑块半径
w = 310, // canvas宽度
h = 155, // canvas高度
PI = Math.PI
const L = l + r * 2 // 滑块实际边长
function getRandomNumberByRange(start, end) {
return Math.round(Math.random() * (end - start) + start)
}
function createCanvas(width, height) {
const canvas = createElement('canvas')
canvas.width = width
canvas.height = height
return canvas
}
function createImg(onload) {
const img = createElement('img')
img.crossOrigin = "Anonymous"
img.onload = onload
img.onerror = function() {
img.src = getRandomImg()
}
img.src = getRandomImg()
return img
}