login.1.js
1.77 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
$(function(){
// 复选框
$('input').iCheck({
checkboxClass: 'icheckbox_square-blue',
radioClass: 'iradio_square-blue',
increaseArea: '20%' // optional
});
// 登陆.规则校验
var loginFormValid = $("#loginForm").validate({
errorElement : 'span',
errorClass : 'help-block',
focusInvalid : true,
rules : {
userName : {
required : true ,
minlength: 5,
maxlength: 18
},
password : {
required : true ,
minlength: 5,
maxlength: 18
}
},
messages : {
userName : {
required :"请输入登陆账号." ,
minlength:"登陆账号不应低于5位",
maxlength:"登陆账号不应超过18位"
},
password : {
required :"请输入登陆密码." ,
minlength:"登陆密码不应低于5位",
maxlength:"登陆密码不应超过18位"
}
},
highlight : function(element) {
$(element).closest('.form-group').addClass('has-error');
},
success : function(label) {
label.closest('.form-group').removeClass('has-error');
label.remove();
},
errorPlacement : function(error, element) {
element.parent('div').append(error);
},
submitHandler : function(form) {
$.post(base_url + "/login", $("#loginForm").serialize(), function(data, status) {
if (data.code == "200") {
ComAlert.show(1, "登陆成功", function(){
window.location.href = base_url;
});
} else {
ComAlert.show(2, data.msg);
}
});
}
});
});