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.

250 lines
9.2 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($("#newUserPwd").val() == ""){
toastr.warning("新密码不能为空!")
return false;
}
if($("#newReUserPwd").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("修改失败!");
}
}
});
});
});
/*
$(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 < 8){
toastr.warning("旧密码长度小于8位")
return false;
}
if($("#newUserPwd").val() == ""){
toastr.warning("新密码不能为空!")
return false;
}
if($("#newUserPwd").val().length < 8){
toastr.warning("新密码长度小于8位")
return false;
}
if($("#newReUserPwd").val() == ""){
toastr.warning("重复密码不能为空!")
return false;
}
if($("#newReUserPwd").val().length < 8){
toastr.warning("重复密码长度小于8位")
return false;
}
reg=/^(?=.*[a-z])(?=.*\d)[a-zA-Z\d]{8,}$/;
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("修改失败!");
}
}
});
});
});
/!**
* 密码强度动态验证
* @param passName
* @constructor
*!/
function AnalyzePasswordSecurityLevel(passName) {
var password =$("#"+passName).val();
var securityLevelFlag = 0;
if (passName == "newReUserPwd") {
if(password == $("#newUserPwd").val()){
if (password.length < 8) {
if (passName == "newUserPwd"){
$("#newUserPwdText").text("");
$("#newUserPwdText").text("密码长度不能小于8位");
}
if (passName == "newReUserPwd") {
$("#newReUserPwdText").text("");
$("#newReUserPwdText").text("密码长度不能小于8位");
}
}
else {
var securityLevelFlagArray = new Array(0, 0, 0, 0);
for (var i = 0; i < password.length; i++) {
var asciiNumber = password.substr(i, 1).charCodeAt();
if (asciiNumber >= 48 && asciiNumber <= 57) {
securityLevelFlagArray[0] = 1; //digital
}
else if (asciiNumber >= 97 && asciiNumber <= 122) {
securityLevelFlagArray[1] = 1; //lowercase
}
else if (asciiNumber >= 65 && asciiNumber <= 90) {
securityLevelFlagArray[2] = 1; //uppercase
}
else {
securityLevelFlagArray[3] = 1; //specialcase
}
}
for (var i = 0; i < securityLevelFlagArray.length; i++) {
if (securityLevelFlagArray[i] == 1) {
securityLevelFlag++;
}
}
if (passName == "newUserPwd"){
if (securityLevelFlag == 1){
$("#newUserPwdText").text("");
$("#newUserPwdText").text("密码安全低");
}
if (securityLevelFlag == 2 || securityLevelFlag == 3){
$("#newUserPwdText").text("");
$("#newUserPwdText").text("密码安全中等");
}
if (securityLevelFlag == 4){
$("#newUserPwdText").text("");
$("#newUserPwdText").text("密码安全高");
}
}
if (passName == "newReUserPwd") {
if (securityLevelFlag == 1){
$("#newReUserPwdText").text("");
$("#newReUserPwdText").text("密码安全低");
}
if (securityLevelFlag == 2 || securityLevelFlag == 3){
$("#newReUserPwdText").text("");
$("#newReUserPwdText").text("密码安全中等");
}
if (securityLevelFlag == 4){
$("#newReUserPwdText").text("");
$("#newReUserPwdText").text("密码安全高");
}
}
}
} else {
$("#newReUserPwdText").text("");
$("#newReUserPwdText").text("两次密码不相同");
}
} else {
if (password.length < 8) {
if (passName == "newUserPwd"){
$("#newUserPwdText").text("");
$("#newUserPwdText").text("密码长度不能小于8位");
}
if (passName == "newReUserPwd") {
$("#newReUserPwdText").text("");
$("#newReUserPwdText").text("密码长度不能小于8位");
}
}
else {
var securityLevelFlagArray = new Array(0, 0, 0, 0);
for (var i = 0; i < password.length; i++) {
var asciiNumber = password.substr(i, 1).charCodeAt();
if (asciiNumber >= 48 && asciiNumber <= 57) {
securityLevelFlagArray[0] = 1; //digital
}
else if (asciiNumber >= 97 && asciiNumber <= 122) {
securityLevelFlagArray[1] = 1; //lowercase
}
else if (asciiNumber >= 65 && asciiNumber <= 90) {
securityLevelFlagArray[2] = 1; //uppercase
}
else {
securityLevelFlagArray[3] = 1; //specialcase
}
}
for (var i = 0; i < securityLevelFlagArray.length; i++) {
if (securityLevelFlagArray[i] == 1) {
securityLevelFlag++;
}
}
if (passName == "newUserPwd"){
if (securityLevelFlag == 1){
$("#newUserPwdText").text("");
$("#newUserPwdText").text("密码安全低");
}
if (securityLevelFlag == 2 || securityLevelFlag == 3){
$("#newUserPwdText").text("");
$("#newUserPwdText").text("密码安全中等");
}
if (securityLevelFlag == 4){
$("#newUserPwdText").text("");
$("#newUserPwdText").text("密码安全高");
}
}
if (passName == "newReUserPwd") {
if (securityLevelFlag == 1){
$("#newReUserPwdText").text("");
$("#newReUserPwdText").text("密码安全低");
}
if (securityLevelFlag == 2 || securityLevelFlag == 3){
$("#newReUserPwdText").text("");
$("#newReUserPwdText").text("密码安全中等");
}
if (securityLevelFlag == 4){
$("#newReUserPwdText").text("");
$("#newReUserPwdText").text("密码安全高");
}
}
}
}
}*/