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 81 82 83 84 85 86 87
| var oldpassword = null; var newpassword = null; var rnewpassword = null; var saveBtn = null;
$(function () { oldpassword = $("#oldpassword"); newpassword = $("#newpassword"); rnewpassword = $("#rnewpassword"); saveBtn = $("#save");
oldpassword.next().html("*"); newpassword.next().html("*"); rnewpassword.next().html("*");
oldpassword.on("blur", function () { $.ajax({ type: "GET", url: path + "/jsp/user.do", data: {method: "pwdmodify", oldpassword: oldpassword.val()}, dataType: "json", success: function (data) { if (data.result == "true") { validateTip(oldpassword.next(), {"color": "green"}, imgYes, true); } else if (data.result == "false") { validateTip(oldpassword.next(), {"color": "red"}, imgNo + " 原密码输入不正确", false); } else if (data.result == "sessionerror") { validateTip(oldpassword.next(), {"color": "red"}, imgNo + " 当前用户session过期,请重新登录", false); } else if (data.result == "error") { validateTip(oldpassword.next(), {"color": "red"}, imgNo + " 请输入旧密码", false); } }, error: function (data) {
validateTip(oldpassword.next(), {"color": "red"}, imgNo + " 请求错误", false); } });
}).on("focus", function () { validateTip(oldpassword.next(), {"color": "#666666"}, "* Please enter the original password", false); }); newpassword.on("focus", function () { validateTip(newpassword.next(), {"color": "#666666"}, "* Password length must be greater than 6 and less than 20", false); }).on("blur", function () { if (newpassword.val() != null && newpassword.val().length > 6 && newpassword.val().length < 20) { validateTip(newpassword.next(), {"color": "green"}, imgYes, true); } else { validateTip(newpassword.next(), {"color": "red"}, imgNo + " Password input does not meet the specification, please re-enter", false); } });
rnewpassword.on("focus", function () { validateTip(rnewpassword.next(), {"color": "#666666"}, "* Please enter the same password as above", false); }).on("blur", function () { if (rnewpassword.val() != null && rnewpassword.val().length > 6 && rnewpassword.val().length < 20 && newpassword.val() == rnewpassword.val()) { validateTip(rnewpassword.next(), {"color": "green"}, imgYes, true); } else { validateTip(rnewpassword.next(), {"color": "red"}, imgNo + " The two passwords are inconsistent, please re-enter", false); } });
saveBtn.on("click", function () { oldpassword.blur(); newpassword.blur(); rnewpassword.blur(); if ( oldpassword.attr("validateStatus") == "true"&& newpassword.attr("validateStatus") == "true" && rnewpassword.attr("validateStatus") == "true") { if (confirm("确定要修改密码?")) { $("#userForm").submit(); } }
}); });
|