//ready,表示文档结构已经加载完成(不包含图片等非文字媒体文件)
$(document).ready(function (){//失去焦点触发
$("#userPsw").blur(function (){checkPsw();});}//检查密码(空、长度和密码强度验证)
var checkPsw = function (){
var userPsw = $("#userPsw").val();if(userPsw ==""){showTip("#userPswTip","请输入密码!");returnfalse;}if(userPsw.length <8|| userPsw.length >16){showTip("#userPswTip","密码为长度8-16位字符");returnfalse;}
var ls =checkPassWordStrength(userPsw);if(ls <3){showTip("#userPswTip","密码必须是包含大写字母,小写字母和数字的组合");returnfalse;}showSuccess("#userPswTip");returntrue;};
function checkPassWordStrength(password){if(password.length <8){return0;}
var ls =0;if(password.match(/([a-z])+/)){ ls++;}if(password.match(/([0-9])+/)){ ls++;}if(password.match(/([A-Z])+/)){ ls++;}if(password.match(/[^a-zA-Z0-9]+/)){ ls++;}return ls;}
var showTip = function (tipId, errorText){hideSuccess(tipId);
$(tipId).addClass("wrong");
$(tipId+"Error").addClass("appear");
$(tipId+"Error").html("<i></i>"+errorText);
var el = tipId.substr(0, tipId.indexOf('Tip'));// $(el).focus();if(isUnVisible($(el))){
$('html,body').animate({scrollTop:($(el).offset().top)},500);//滚动到错误提示处}
$(el).css("border",'1px solid #ff2a00');};
var showSuccess = function (tipId){hideTip(tipId)
$(tipId).show();
$(tipId).addClass("right");};
var hideSuccess = function (tipId){
$(tipId).hide();
$(tipId).removeClass("right");};