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

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

$(function() {
var isOldValid = true;
//清空
$('#btn_clear').click(function () {
$("#newUserPwd").val("");
$("#newReUserPwd").val("");
isOldValid = true;
});
//提交更改
$('#btn_submit').click(function () {
if($("#userPwd").val() == ""){
toastr.warning("旧密码不能为空!")
return false;
}
if($("#userPwd").val().length < 6){
toastr.warning("旧密码长度小于6位")
return false;
}
if($("#newUserPwd").val() == ""){
toastr.warning("新密码不能为空!")
return false;
}
if($("#newUserPwd").val().length < 6){
toastr.warning("新密码长度小于6位")
return false;
}
if($("#newReUserPwd").val() == ""){
toastr.warning("重复密码不能为空!")
return false;
}
if($("#newReUserPwd").val().length < 6){
toastr.warning("重复密码长度小于6位")
return false;
}
reg=/^(?=.*[a-z])(?=.*\d)[a-zA-Z\d]{6,}$/;
if (!reg.test($("#newUserPwd").val())) {
toastr.warning("密码格式必须包含数字和字母!")
return false;
}
if($("#newReUserPwd").val() != $("#newUserPwd").val() ){
toastr.warning("重复密码与密码不一致!")
return false;
}
$.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("修改失败!");
}
}
});
});
/*//验证旧密码
$('#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;
}
}
});
})*/
});