[javascript]代码库// 密码验证
function checkPassword() {
var password = $("#password").val();
if (password.length < 1) {
$("#passwordWrong").html("*请输入密码!");
return false;
} else if (password.length < 6 || password.length > 22) {
$("#passwordWrong").html("*密码长度不正确!");
return false;
} else {
$("#passwordWrong").html("密码长度正确。");
return true;
}
}
// 检查密码格式
function checkPassword() {
var password = document.getElementById("password").value;
var re = /^[\@A-Za-z0-9\!\#\$\%\^\&\*\.\~]{6,22}$/; //6-22位
var result = re.test(password);
document.getElementById('passwordDiv').style.visibility = "visible";
if (result) {
document.getElementById('passwordDiv').className = "yes";
$("#passwordError").html("格式正确!");
return true;
} else {
document.getElementById('passwordDiv').className = "wrong";
$("#passwordError").html("密码长度为6-22位!");
return false;
}
}