-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathregist.html
More file actions
50 lines (46 loc) · 1.75 KB
/
regist.html
File metadata and controls
50 lines (46 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>注册页面</title>
<script src="./jq/lib/jquery-3.3.1.min.js"></script>
<script>
//在页面加载完成后
$(function () {
//给username绑定blur事件
$("#username").blur(function () {
//获取username文本输入框的值
var username = $(this).val();
//发送ajax请求
//期望服务器响应回的数据格式:{"userExsit":true,"msg":"此用户名太受欢迎,请更换一个"}
// {"userExsit":false,"msg":"用户名可用"}
$.get("find_user_servlet",{username:username}, function (data) {
var span = $("#s_username");
alert(data);
//判断userExsit键的值是否是true
if (data.userExsit) {
//用户名存在
span.css("color","red");
span.html(data.msg);
} else {
//用户名不存在
span.css("color","green");
span.html(data.msg);
}
});
// 客户端使用时,要想当做json数据格式使用
// $.get(type):将最后一个参数type指定为"json"
});
})
</script>
</head>
<body>
<form>
<input type="text" id="username" name="username" placeholder="请输入用户名">
<span id="s_username"></span>
<br>
<input type="password" name="password" placeholder="请输入密码">
<input type="submit" value="注册">
</form>
</body>
</html>