Commit 04833bf420b59cbaca776fd8c696c5cb86eee9cb
Merge branch 'pudong' of 192.168.168.201:panzhaov5/bsth_control into pudong
Showing
1 changed file
with
63 additions
and
8 deletions
src/main/resources/static/pages/permission/user/changePWD.html
| @@ -4,6 +4,9 @@ | @@ -4,6 +4,9 @@ | ||
| 4 | <div class="portlet light portlet-fit portlet-form bordered"> | 4 | <div class="portlet light portlet-fit portlet-form bordered"> |
| 5 | <div class="portlet-body"> | 5 | <div class="portlet-body"> |
| 6 | <form class="form-horizontal" id="changePWDForm"> | 6 | <form class="form-horizontal" id="changePWDForm"> |
| 7 | + <div class="alert alert-danger display-hide"> | ||
| 8 | + <button class="close" data-close="alert"></button>您的输入有误,请检查下面的输入项 | ||
| 9 | + </div> | ||
| 7 | <div class="form-group" style="margin-top: 60px"> | 10 | <div class="form-group" style="margin-top: 60px"> |
| 8 | <label class="control-label col-md-5">原始密码: | 11 | <label class="control-label col-md-5">原始密码: |
| 9 | </label> | 12 | </label> |
| @@ -19,7 +22,7 @@ | @@ -19,7 +22,7 @@ | ||
| 19 | <div class="col-md-4"> | 22 | <div class="col-md-4"> |
| 20 | <div class="input-icon right"> | 23 | <div class="input-icon right"> |
| 21 | <i class="fa"></i> | 24 | <i class="fa"></i> |
| 22 | - <input type="password" class="form-control" name="newPWD" /> </div> | 25 | + <input type="password" class="form-control" name="newPWD" id="newPWD"/> </div> |
| 23 | </div> | 26 | </div> |
| 24 | </div> | 27 | </div> |
| 25 | <div class="form-group"> | 28 | <div class="form-group"> |
| @@ -34,7 +37,7 @@ | @@ -34,7 +37,7 @@ | ||
| 34 | <div class="form-actions"> | 37 | <div class="form-actions"> |
| 35 | <div class="row"> | 38 | <div class="row"> |
| 36 | <div class="col-md-offset-5 col-md-7"> | 39 | <div class="col-md-offset-5 col-md-7"> |
| 37 | - <button type="button" id="confirm" class="btn green">确定</button> | 40 | + <button type="submit" id="confirm" class="btn green">确定</button> |
| 38 | <button type="reset" class="btn default">取消</button> | 41 | <button type="reset" class="btn default">取消</button> |
| 39 | </div> | 42 | </div> |
| 40 | </div> | 43 | </div> |
| @@ -47,11 +50,63 @@ | @@ -47,11 +50,63 @@ | ||
| 47 | 50 | ||
| 48 | <script> | 51 | <script> |
| 49 | $(function(){ | 52 | $(function(){ |
| 50 | - $("#confirm").on("click",function(){ | ||
| 51 | - var data = $('#changePWDForm').serializeJSON(); | ||
| 52 | - $.post('/user/changePWD',data,function(msg){ | ||
| 53 | - layer.alert(msg); | ||
| 54 | - }); | ||
| 55 | - }); | 53 | + var form = $('#changePWDForm'); |
| 54 | + //表单 validate | ||
| 55 | + var error = $('.alert-danger', form); | ||
| 56 | + | ||
| 57 | + $.validator.addMethod("passwordrule", function(value, element) { | ||
| 58 | + //var userblank = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*?[#?!@$%^&*-]).{8,16}$/; | ||
| 59 | + var userblank = /^(?=.*[a-zA-Z])(?=.*\d).{8,16}$/; | ||
| 60 | + return this.optional(element) ||(userblank.test(value)); | ||
| 61 | + }, "需包含字母、数字的8-16位字符"); | ||
| 62 | + | ||
| 63 | + //表单 validate | ||
| 64 | + form.validate({ | ||
| 65 | + errorElement : 'span', | ||
| 66 | + errorClass : 'help-block help-block-error', | ||
| 67 | + focusInvalid : false, | ||
| 68 | + rules : { | ||
| 69 | + 'newPWD' : { | ||
| 70 | + required : true, | ||
| 71 | + minlength: 8, | ||
| 72 | + maxlength: 16, | ||
| 73 | + passwordrule:true | ||
| 74 | + }, | ||
| 75 | + 'cnewPWD' : { | ||
| 76 | + equalTo: '#newPWD' | ||
| 77 | + } | ||
| 78 | + }, | ||
| 79 | + invalidHandler : function(event, validator) { | ||
| 80 | + error.show(); | ||
| 81 | + App.scrollTo(error, -200); | ||
| 82 | + }, | ||
| 83 | + | ||
| 84 | + highlight : function(element) { | ||
| 85 | + $(element).closest('.form-group').addClass('has-error'); | ||
| 86 | + }, | ||
| 87 | + | ||
| 88 | + unhighlight : function(element) { | ||
| 89 | + $(element).closest('.form-group').removeClass('has-error'); | ||
| 90 | + }, | ||
| 91 | + | ||
| 92 | + success : function(label) { | ||
| 93 | + label.closest('.form-group').removeClass('has-error'); | ||
| 94 | + }, | ||
| 95 | + | ||
| 96 | + submitHandler : function(f) { | ||
| 97 | + var params = form.serializeJSON(); | ||
| 98 | + error.hide(); | ||
| 99 | + | ||
| 100 | + $.ajax({ | ||
| 101 | + url: '/user/changePWD', | ||
| 102 | + type: 'POST', | ||
| 103 | + traditional: true, | ||
| 104 | + data: params, | ||
| 105 | + success: function(msg){ | ||
| 106 | + layer.alert(msg); | ||
| 107 | + } | ||
| 108 | + }); | ||
| 109 | + } | ||
| 110 | + }); | ||
| 56 | }); | 111 | }); |
| 57 | </script> | 112 | </script> |
| 58 | \ No newline at end of file | 113 | \ No newline at end of file |