12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- $(function () {
- $("#changePwd").on("click", function (e) {
- e.preventDefault();
- var password = $("#password");
- var password1 = $("#password1");
- if (password.val().trim() === "") {
- showMsg("请输入密码", 2, 1000);
- password.focus();
- return;
- }
- if (password1.val().trim() === "") {
- showMsg("请再次输入密码", 2, 1000);
- password1.focus();
- return;
- }
- if (password.val().trim() === password1.val().trim()) {
- fetchJSON(
- "api/user/update",
- {
- userId:sessionStorage.getItem("userId"),
- userAccount: sessionStorage.getItem("userAccount"),
- userPassword: password.val().trim(),
- },
- "post",
- function (ret) {
- if (ret.code === 0) {
- fetchJSON("api/user/logout", {}, "post", function (data) {
- showMsg("修改成功,请重新登陆",2,1000);
- sessionStorage.setItem("userId", -1);
- sessionStorage.setItem("userAccount", "");
- window.login = "login";
- window.location.href = "../../index.html";
- });
- } else {
- showMsg(ret.msg, 2, 1000);
- if (data.code === 6) {
- showMsg("修改失败", 2);
- $("#username").focus();
- } else {
- showMsg(data.data, 2);
- }
- }
- }
- );
- } else {
- showMsg("两次密码不匹配", 2, 1000);
- return;
- }
- });
- });
- //身份证验证
- function is_idcard(id) {
- var idcardReg = /^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$|^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/;
- if(idcardReg.test(id))
- return true;
- else
- return false;
- }
|