首页 > 代码库 > 密码验证
密码验证
<html>
<head>
<title></title>
<meta charset="UTF-8" />
<script src="http://www.mamicode.com/js/jquery-2.1.0.js" type="text/javascript" charset="utf-8"></script>
<script src="http://www.mamicode.com/js/aa.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
function valijs(ele){
var now=$(ele).val();
var re = new RegExp("[a-zA-Z]");
var len=re.test(now);
re = new RegExp("[0-8]");
len=re.test(now);
re = new RegExp("((?=[\x21-\x7e]+)[^A-Za-z0-9])");
len=re.test(now);
if(len){
return true;
}
//alert("密码强度不符合,请重新输入");
return false;
}
$(function(){
$(‘button‘).on(‘click‘,function(){
var flag = valijs(‘#txt‘);
alert(flag);
});
});
</script>
</head>
<body>
<button>button</button>
<input type="text" name="txt" id="txt" value="" />
</body>
</html>
密码验证