标签:定义 -- *** count 编写 sdi control 引入 hal
输入密码判断密码强度
安全强度:*低
安全强度:***中
安全强度:*****高
<style type="text/css">
.show-green{
color: green;
}
.show-yellow{
color: orange;
}
.show-red{
color: red;
}
</style>
<input type="password" class="form-control" name="password" id="inputaccount" ng-model="password" ng-keyup="checkPassword(password)" placeholder="6-16位数字或英文字母">
<p class="text-right grey show-{{teColor}}" ng-bind="safeMsg"></p>---------------------------文字显示
//输入密码 键盘弹起事件 判断密码强度
$scope.checkPassword = function(password){
//$scope.safeMsg = "安全强度:*";
//$scope.teColor = "red";
//正则表达式判断密码强度
var lowTest1 = /^\d{1,6}$/; //纯数字
var lowTest2 = /^[a-zA-Z]{1,6}$/; //纯字母
var halfTest = /^[A-Za-z0-9]{1,6}$/;
var halfTest2 = /^[A-Za-z0-9]{6,8}$/;
var highTest = /^[A-Za-z0-9]{6,16}$/;
if(lowTest1.test(password)|lowTest2.test(password)|halfTest.test(password)){
$scope.safeMsg = "安全强度:*低";
$scope.teColor = "red";
}else if(halfTest2.test(password)){
$scope.safeMsg = "安全强度:***中";
$scope.teColor = "yellow";
}else if(highTest.test(password)){
$scope.safeMsg = "安全强度:*****高";
$scope.teColor = "green";
$scope.repassDis = "false";
}else{
$scope.safeMsg = "密码不符合要求";
$scope.teColor = "red";
}
};
标签:定义 -- *** count 编写 sdi control 引入 hal
原文地址:http://www.cnblogs.com/kaisens/p/7899694.html