代码拉取完成,页面将自动刷新
/**
* 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)
}
}
});
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。