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
76
77
78
79
80
| window.I = {}
| var basic = getpath();
| var modelview = function() {
| var self = this;
| self.opwd = ko.observable();
| self.npwd = ko.observable();
| self.rnpwd = ko.observable();
| }
| jQuery(document).ready(
| function($) {
| var flag = true;
| var md = window.md = new modelview();
| ko.applyBindings(md);
| var fm1 = $('#fm1');
| fm1.validate({
| rules : {
| opwd : "required",
| npwd : {
| required : true,
| maxlength : 16,
| minlength : 6
| },
| rnpwd : {
| required : true,
| equalTo : '#npwd',
| maxlength : 16,
| minlength : 6
| }
| },
| messages : {
| opwd : "请输入旧密码",
| npwd : {
| required : "请输入新密码",
| maxlength : '最大长度不能超过16',
| minlength : '最小长度不能小于6'
| },
| rnpwd : {
| required : "请输入新密码确认",
| maxlength : '最大长度不能超过16',
| minlength : '最小长度不能小于6',
| equalTo : '#新密码前后输入不一致,请重新输入'
| }
| }
| });
| $("#npwd").change(function() {
| var opwd = $("#opwd").val();
| var npwd = $("#npwd").val();
| if (opwd == npwd) {
| flag=false;
| alert("新密码和旧密码不能一致,请重新输入!");
| }
| })
| $('#tjbtn').click(
| function(event) {
| /* Act on the event */
| if (!fm1.valid()||flag==false)
| return;
| var obj = {};
| obj.oldpwd = md.opwd();
| obj.newpwd = md.npwd();
| obj.rnpwd = md.rnpwd();
| jQuery.post(basic + '/system/savePwd.htm',
| obj, function(data, textStatus, xhr) {
| // optional stuff to do after success
| if (data == null) {
| // showErrmsg('系统没有响应!');
| swal({title:'',text:'系统没有响应!',type:'error',confirmButtonText:'确定'});
| return;
| }
| if (data.code == 0) {
| showErrmsg('密码修改成功!');
| return;
| } else {
| swal({title:'',text:'密码失败,请重新修改!',type:'error',confirmButtonText:'确定'});
| // showErrmsg('密码失败,请重新修改!');
| return;
| }
| }, 'json');
| });
| });
|
|