加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
regPCagu.js 4.65 KB
一键复制 编辑 原始数据 按行查看 历史
/**
* Created by chenke on 2017/5/16.
*/
var myMoudle = angular.module("regPCapp",[]);
myMoudle.controller("regctr",function($scope){
$scope.disNum = true;
var disnum1 = true,disnum2 = true;
var disnum3 = true,disnum4 = true;
var disnum5 = true,disnum6 = true;
//监控账号输入框
$scope.$watch('username',function(body){
if(body){
var reg = /^1[34578]\d{9}$/;
var user = reg.test($scope.username);
if(user){
$scope.ngcolor1 ="greencolor";
disnum1 = false
}else{
$scope.ngcolor1 = "redcolor";
disnum1 = true;
tipfun(tiphtml1);
}
$scope.disNum = btnuse(disnum1,disnum2,disnum4);
}
});
//密码输入框的监视
$scope.$watch('userpass1',function(body){
if(body){
var reg = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])[a-zA-Z\d]{6,20}$/; //密码必须有大小写字母和数字且6-20位
var pass = reg.test($scope.userpass1);
if(pass){
$scope.ngcolor2 = "greencolor";
disnum2 = false;
//console.log(pass+"7485745");
//alert("sdadsad")
}else{
$scope.ngcolor2 = "redcolor";
disnum2 = true;
tipfun(tiphtml1);
}
$scope.disNum = btnuse(disnum1,disnum2,disnum4);
}
});
//确认密码输入框的监视
$scope.$watch('userpass2',function(body){
if(body){
var user1 = $scope.userpass1;
var user2 = $scope.userpass2;
var reg = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])[a-zA-Z\d]{6,20}$/; //密码必须有大小写字母和数字且6-20位
var pass = reg.test($scope.userpass2);
if(pass){
if(user1 == user2){
$scope.ngcolor3 = 'greencolor';
disnum4 = false;
}else{
$scope.ngcolor3 = 'redcolor';
disnum4 = true;
tipfun(tiphtml2);
}
}else{
$scope.ngcolor3 = "redcolor";
}
$scope.disNum = btnuse(disnum1,disnum2,disnum4);
}
});
//当账号输入框失去焦点后的判断函数
$scope.blurfun1 = function(){
var user = $scope.username;
if(user==''||user==undefined||user==null){
$scope.ngcolor1 = 'redcolor';
//disnum1 = true;
tipfun(tiphtml1);
}
};
//当密码输入框失去焦点后的判断函数
$scope.blurfun2 = function(){
var user = $scope.userpass1;
if(user==''||user==undefined||user==null){
$scope.ngcolor2 = 'redcolor';
//disnum2 = true;
tipfun(tiphtml1);
}
};
//当确认密码输入框失去焦点后的判断函数
$scope.blurfun3 = function(){
var user1 = $scope.userpass1;
var user2 = $scope.userpass2;
if(user2==''||user2==undefined||user2==null){
$scope.ngcolor3 = 'redcolor';
tipfun(tiphtml1);
}else{
if(user1 == user2){
$scope.ngcolor3 = 'greencolor';
}else{
$scope.ngcolor3 = 'redcolor';
tipfun(tiphtml2);
}
}
};
//注册按钮的可用性判断函数
function btnuse(a1,a2,a3){
if(a1 == false && a2 == false && a3 == false){
return false
}else{
return true
}
}
//对输入框的内容判断弹出框
var tiphtml1 = '<div class="alert alert-danger alert-dismissible fade in" role="alert" ' +
' style=" margin-top: 10px; margin-right: -20px;margin-left: 20px;"> ' +
'<button type="button" class="close" data-dismiss="alert" aria-label="Close">' +
'<span aria-hidden="true">×</span></button>' +
'注册提示:账号和密码都不能为空且必须按照格式填写。</div>';
var tiphtml2 = '<div class="alert alert-danger alert-dismissible fade in" role="alert" ' +
' style=" margin-top: 10px; margin-right: -20px;margin-left: 20px;"> ' +
'<button type="button" class="close" data-dismiss="alert" aria-label="Close">' +
'<span aria-hidden="true">×</span></button>' +
'注册提示:两次输入的密码不一致。</div>';
var nonehtml = "";
function tipfun(tiphtml){
var num = $('.tipdiv').children().length;
if(num <= 0){
$('.tipdiv').append(tiphtml);
setTimeout(function(){
$('.tipdiv').html(nonehtml);
},2000)
}
}
});
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化