修改密码方法:
function changePwd(){
var oldPwd = $("#oldPwd").val();
var newPwd = $("#newPwd").val();
var newPwd2 = $("#newPwd2").val();
if(oldPwd=="" ||oldPwd==null){
bt_alert('提示','登录密码不能为空');
return;
}
if(newPwd=="" ||newPwd==null ){
bt_alert('提示','修改密码不能为空');
return;
}
if(!vpwd(newPwd)){
return;
}
if(newPwd2=="" ||newPwd2==null ){
bt_alert('提示','确认密码不能为空');
return;
}
if(!vpwd(newPwd2)){
return;
}
if(newPwd != newPwd2){
bt_alert('提示','修改密码与确认密码不一致');
return;
}
if(oldPwd == newPwd){
bt_alert('提示','旧密码不能与新密码相同');
return;
}
var oldPwdn = hex_md5(oldPwd);
var newPwdn = hex_md5(newPwd);
var newPwd2n = hex_md5(newPwd2);
$.ajax({
type: "POST",
url:'<%=path%>/ajaxChangePwd.action',
data:{
oldPwd:oldPwdn,
newPwd:newPwdn,
newPwd2:newPwd2n,
},
async: false,
success: function(result) {
if(result=='1'){
bt_alert('提示','修改成功');
// bt_alert('提示','密码修改成功',function(){
window.parent.location='<%=path%>/outLogin.action';
//});
}else if(result=='FF'){
bt_alert('提示','登录密码不对,请确认',function(){
window.location.href='<%=path%>/loadEditPwd.action';
});
}else{
bt_alert('提示','密码修改失败',function(){
window.location.href='<%=path%>/loadEditPwd.action';
});
}
}
});
}
function vpwd(now){
var re1 = new RegExp("[a-zA-Z]");//字母
var len1=re1.test(now);
var re2 = new RegExp("[0-9]");//数字
var len2=re2.test(now);
var re3 = new RegExp("[^a-zA-Z0-9]");//特殊符号
var len3=re3.test(now);
var re4 = new RegExp("[\u4E00-\u9FFF]+","g");//中文
var len4=re4.test(now);
//不能相同字符(如111、aaa)连续3位或3位以上
var re5 = /(w)*(w)2{2}(w)*/g;
if(re5.test(now)){
bt_alert("提示","不能相同的字符连续3位或3位以上");
return false;
}
if(!LxStr(now)){
bt_alert("提示", "不能连续字符,连续3位或3位以上");
return false;
}
if(re4.test(now)){
bt_alert('提示','不应包含汉字!');
return false;
}
if(now.length<6 || now.length>20){
bt_alert('提示','密码长度应在6-20!');
return false;
}
if(len1 && len2 && len3){
return true;
}else{
bt_alert('提示','密码强度不符合,至少6位且至少包含数字字母特殊符号各一位!');
return false;
}
}
//校验不能是连续字符方法
LxStr = function(str){
var arr = str.split('');
var flag = true;
for (var i = 1; i < arr.length-1; i++) {
var firstIndex = arr[i-1].charCodeAt();
var secondIndex = arr[i].charCodeAt();
var thirdIndex = arr[i+1].charCodeAt();
thirdIndex - secondIndex == 1;
secondIndex - firstIndex==1;
if((thirdIndex - secondIndex == 1)&&(secondIndex - firstIndex==1)){
flag = false;
}
}
if(!flag){
$("#message_").text("您的工号为弱口令密码,请修改密码后登录!");
return flag;
}
return flag;
}