-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreg.html
247 lines (233 loc) · 6.76 KB
/
reg.html
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
<!DOCTYPE html>
<html class="ui-page-login">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
<title></title>
<link href="css/mui.min.css" rel="stylesheet" />
<link href="css/style.css" rel="stylesheet" />
<style>
.topper
{
background-color:#29c4b5;
font-size: 20px;
margin:0;
margin-bottom: 1%;
padding-top: 0.3px;
padding-bottom: 0.3px;
text-align: center;
font-weight:bold;
color:#FFFFFF;
}
.area {
margin: 20px auto 0px auto;
}
.mui-input-group label {
width: 22%;
}
.mui-input-row input{
width:30%;
padding: 0.5em 4em 0.5em 0em;
-webkit-border-radius:.3em;
-moz-border-radius: .3em;
border: 1px solid #999;
background-color: #EFEFF4;
}
.mui-input-row{
margin-left: 5%;
}
.mui-input-group:first-child {
margin-top: 20px;
}
.mui-input-row label~input,
.mui-input-row label~select,
.mui-input-row label~textarea {
width: 78%;
}
.mui-checkbox input[type=checkbox],
.mui-radio input[type=radio] {
top: 6px;
}
.mui-content-padded {
margin-top: 25px;
}
.mui-btn {
padding: 10px;
}
.title{
text-align:center;
}
.choice{
margin-left: 5%;
margin-top: 2%;;
}
.login_btn{
width:300px;
margin:30px auto 0 auto;
}
.login_btn button{
width:100%;
margin:0;
padding:.3em 0;
-webkit-border-radius:.3em;
-moz-border-radius: .3em;
border:#1263be solid 1px;
background-color: #29C4B5;
color:#FFF;
font-size:17px;
font-weight:bolder;
letter-spacing:1em;
}
.login_btn button:hover{
background-color: cadetblue;
}
</style>
</head>
<body>
<header class="mui-bar mui-bar-nav">
<a class="mui-icon mui-icon-left-nav mui-pull-left" href="login.html"></a>
<h1 class="mui-title">注册</h1>
</header>
<div class="mui-content">
<form class="mui-input-group">
<div class="mui-input-row">
<label>账号</label>
<input id='account' type="text" class="mui-input-clear mui-input" placeholder="请输入账号">
</div>
<div class="mui-input-row">
<label>昵称</label>
<input id='nickname' type="text" class="mui-input-clear mui-input" placeholder="请输入昵称">
</div>
<div class="mui-input-row">
<label>密码</label>
<input id='password' type="password" class="mui-input-clear mui-input" placeholder="请输入密码">
</div>
<div class="mui-input-row">
<label>确认</label>
<input id='password_confirm' type="password" class="mui-input-clear mui-input" placeholder="请确认密码">
</div>
<div class="mui-input-row">
<label>邮箱</label>
<input id='email' type="email" class="mui-input-clear mui-input" placeholder="请输入邮箱">
</div>
<div class="choice">
<label class="label" for="remembercheck">
<input type="checkbox" name="frm_checkbox" id="student">
" 学生用户 "
</label>
<label class="label" for="remembercheck">
<input type="checkbox" name="frm_checkbox" id="teacher">
" 教师用户 "
</label>
</div>
</form>
<div class="mui-content-padded">
<div class="login_btn">
<button id='reg' class="mui-btn mui-btn-block mui-btn-primary">注册</button>
</div>
</div>
<div class="mui-content-padded">
<p>点击上面的“注册”按钮,即表示你同意《集智测评软件许可及服务协议》。</p>
</div>
</div>
<script src="js/mui.min.js"></script>
<script src="js/app.js"></script>
<script src="js/url.js"></script>
<script>
(function($, doc) {
$.init({
statusBarBackground: '#f7f7f7',
});
//var url=127.0.0.1:8080;
// var url='210.36.22.231';
var settings = app.getSettings();
var regButton = doc.getElementById('reg');
var accountBox = doc.getElementById('account');
var nicknameBox = doc.getElementById('nickname');
var passwordBox = doc.getElementById('password');
var passwordConfirmBox = doc.getElementById('password_confirm');
var emailBox = doc.getElementById('email');
var student = doc.getElementById("student");
var teacher = doc.getElementsByClassName("teacher");
var toMain = function() {
//使用定时器的原因:
//可能执行太快,main页面loaded事件尚未触发就执行自定义事件,此时必然会失败
var id = setInterval(function() {
clearInterval(id);
$.openWindow({
url: 'login.html',
id: 'login',
})
}, 20);
};
regButton.onclick = function(){
var passwordConfirm = passwordConfirmBox.value;
if (passwordConfirm != passwordBox.value) {
alert('密码两次输入不一致!');
return;
};
//对电子邮件的验证
var email = emailBox.value;
var myreg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
if(!myreg.test(email)){
alert('请输入有效邮箱!');
return;
}
if(document.getElementById("student").checked!=true&&document.getElementById("teacher").checked!=true){
alert("请选择用户类型!");
return;
}
if(document.getElementById("student").checked==true)
{
var regInfo = {
account: accountBox.value,
nickname:nicknameBox.value,
password: passwordBox.value,
email: emailBox.value,
usertype:1
};
}
if(document.getElementById("teacher").checked==true)
{
var regInfo = {
account: accountBox.value,
nickname:nicknameBox.value,
password: passwordBox.value,
email: emailBox.value,
usertype:2
};
};
mui.ajax('http://'+url+'/jizhibackend/servlet/RegisterServlet', {
data: {
username: regInfo.account,
nickname:regInfo.nickname,
password: regInfo.password,
email: regInfo.email,
usertype:regInfo.usertype,
},
xhrFields: {
withCredentials: true
},
crossDomain: true,
dataType: 'text', //服务器返回json格式数据
type: 'get', //HTTP请求类型
timeout: 1000000, //超时时间设置为10秒;
headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' },
success: function(data) {
if(data != 'error') {
alert('注册成功!')
toMain();
} else {
alert('注册失败!')
}
},
error: function(xhr, type, errorThrown) {
//异常处理;
alert(data);
}
});
}
}(mui, document));
</script>
</body>
</html>