68875634dd894434a8ba54dc2b809ce92affbdc6.svn-base 2.0 KB

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