forked from maxliaops/Java_Web_Examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuser.js
More file actions
75 lines (75 loc) · 1.85 KB
/
user.js
File metadata and controls
75 lines (75 loc) · 1.85 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
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
function register(form) {
var userName = $.trim($('#userName').val());
if (!userName) {
alert('用户名称不能为空');
return;
}
$.ajax( {
url : 'userAction_findUserByUserName',
type : 'POST',
processDate : true,
data : $('#registerForm').serialize(),
dataType : 'json',
success : function(data) {
if (data.userExsist == true) {
alert('用户名称已经存在');
return;
}
var psw = $.trim($('#password').val());
if (psw.length > 15 || psw < 6) {
alert('密码长度不对,请重新输入');
return;
}
var confirmPassword = $.trim($('#confirmPassword').val()); //取得id为confirmPassword的文本库的值,并将前后空格去掉
if (!psw) {
alert('密码不能为空');
return;
}
if (psw != confirmPassword) {
alert('两次密码输入不一致');
$('#password').val('');
$('#confirmPassword').val('');
return;
}
$('#' + form)[0].submit();
}
});
}
function update() {
var userName = $.trim($('#userName').val());
if (!userName) {
alert('用户名称不能为空');
return;
}
var psw = $.trim($('#password').val());
if (psw.length > 15 || psw < 6) {
alert('密码长度不对,请重新输入');
return;
}
var confirmPassword = $.trim($('#confirmPassword').val());
if (!psw) {
alert('密码不能为空');
return;
}
if (psw != confirmPassword) {
alert('两次密码输入不一致');
$('#oldPassword').val('');
$('#password').val('');
$('#confirmPassword').val('');
return;
}
$.ajax( {
url : 'userAction_updateUser',
type : 'POST',
processDate : true,
data : $('#updateUserForm').serialize(),
dataType : 'json',
success : function(data) {
if (success == false) {
alert(data.msg);
return;
}
location.href = 'userAction_toSuccessPage';
}
});
}