提交 | 用户 | 时间
|
e7c126
|
1 |
$(function(){ |
H |
2 |
|
|
3 |
// input iCheck |
|
4 |
$('input').iCheck({ |
|
5 |
checkboxClass: 'icheckbox_square-blue', |
|
6 |
radioClass: 'iradio_square-blue', |
|
7 |
increaseArea: '20%' // optional |
|
8 |
}); |
|
9 |
|
|
10 |
// login Form Valid |
|
11 |
var loginFormValid = $("#loginForm").validate({ |
|
12 |
errorElement : 'span', |
|
13 |
errorClass : 'help-block', |
|
14 |
focusInvalid : true, |
|
15 |
rules : { |
|
16 |
userName : { |
|
17 |
required : true , |
|
18 |
minlength: 4, |
|
19 |
maxlength: 18 |
|
20 |
}, |
|
21 |
password : { |
|
22 |
required : true , |
|
23 |
minlength: 4, |
|
24 |
maxlength: 18 |
|
25 |
} |
|
26 |
}, |
|
27 |
messages : { |
|
28 |
userName : { |
|
29 |
required : I18n.login_username_empty, |
|
30 |
minlength : I18n.login_username_lt_4 |
|
31 |
}, |
|
32 |
password : { |
|
33 |
required : I18n.login_password_empty , |
|
34 |
minlength : I18n.login_password_lt_4 |
|
35 |
/*,maxlength:"登录密码不应超过18位"*/ |
|
36 |
} |
|
37 |
}, |
|
38 |
highlight : function(element) { |
|
39 |
$(element).closest('.form-group').addClass('has-error'); |
|
40 |
}, |
|
41 |
success : function(label) { |
|
42 |
label.closest('.form-group').removeClass('has-error'); |
|
43 |
label.remove(); |
|
44 |
}, |
|
45 |
errorPlacement : function(error, element) { |
|
46 |
element.parent('div').append(error); |
|
47 |
}, |
|
48 |
submitHandler : function(form) { |
|
49 |
$.post(base_url + "/login", $("#loginForm").serialize(), function(data, status) { |
|
50 |
if (data.code == "200") { |
|
51 |
layer.msg( I18n.login_success ); |
|
52 |
setTimeout(function(){ |
|
53 |
window.location.href = base_url + "/"; |
|
54 |
}, 500); |
|
55 |
} else { |
|
56 |
layer.open({ |
|
57 |
title: I18n.system_tips, |
|
58 |
btn: [ I18n.system_ok ], |
|
59 |
content: (data.msg || I18n.login_fail ), |
|
60 |
icon: '2' |
|
61 |
}); |
|
62 |
} |
|
63 |
}); |
|
64 |
} |
|
65 |
}); |
|
66 |
}); |