You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

88 lines
2.5 KiB
JavaScript

5 years ago
$(function() {
var isOldValid = true;
//清空
$('#btn_clear').click(function () {
$("#newUserPwd").val("");
$("#newReUserPwd").val("");
isOldValid = true;
});
//提交更改
$('#btn_submit').click(function () {
/*if($("#userPwd").val() == ""){
5 years ago
toastr.warning("旧密码不能为空!")
return false;
}
if($("#userPwd").val().length < 8){
toastr.warning("旧密码长度小于8位")
5 years ago
return false;
}*/
5 years ago
if($("#newUserPwd").val() == ""){
toastr.warning("新密码不能为空!")
return false;
}
if($("#newUserPwd").val().length < 8){
toastr.warning("新密码长度小于8位")
5 years ago
return false;
}
if($("#newReUserPwd").val() == ""){
toastr.warning("重复密码不能为空!")
return false;
}
if($("#newReUserPwd").val().length < 8){
toastr.warning("重复密码长度小于8位")
5 years ago
return false;
}
reg=/^(?=.*[a-z])(?=.*\d)[a-zA-Z\d]{8,}$/;
if (!reg.test($("#newUserPwd").val())) {
toastr.warning("密码格式必须包含数字和字母!")
return false;
}
5 years ago
if($("#newReUserPwd").val() != $("#newUserPwd").val() ){
toastr.warning("重复密码与密码不一致!")
return false;
}
5 years ago
$.ajax({
type: "post",
url: path+"/user/updatePassword",
data:{userPwd : $("#newUserPwd").val()},
dataType:'json',
success: function(data){
if(data.extend.result){
toastr.success("修改成功!");
setTimeout(function(){
window.location.reload();
},1000)
}else{
toastr.error("修改失败!");
}
}
});
});
5 years ago
/*//验证旧密码
$('#userPwd').blur(function () {
$.ajax({
type: "post",
url: path+"/user/updatePassword",
data:{userPwd : $("#userPwd").val()},
async:false,
success: function(data){
if( ! data.extend.result){
toastr.warning("旧密码输入错误!");
isOldValid = false;
}else{
isOldValid = true;
}
}
});
})*/
});