在angular 6中更改动态输入中的密码指令内容?
Change the password Instruction Content in Dynamically based input in angular 6?
enter image description here
当用户给出大写字母时,删除指令中的大写单词,当给出特殊字符时,删除 spl 字符...,当字段为空时,显示旧指令。
<input type="password" (keyup)="error_message()" value='user_password'/>
<label>{{instruction}}</label>
error_message()
{
if(this.user_password=="")
{
this.instruction = "Password Need 6-13 Characters With Numbers,Uppercase,Spl Characters";
}
else
{
const regx = new RegExp("(?=.*?[A-Z])");
const Regx_speChar = new RegExp("(?=.*?[#?!@$%^&*-])");
const Regx_number = new RegExp("(?=.*?[0-9])");
const password_caps = this.user_password.match(regx)?true:false;
const password_splcase = this.user_password.match(Regx_speChar)?true:false;
const password_numbers = this.user_password.match(Regx_number)?true:false;
if( password_caps!=true && password_splcase!=true && password_numbers!=true)
{
this.instruction = "Password Need 6-13 Characters With Numbers,Uppercase,Spl Characters";
}
else if( password_caps==true && password_splcase !=true && password_numbers !=true )
{
this.instruction = "Password Need 6-13 Characters With Numbers,Spl Characters";
}
else if( password_caps!=true && password_splcase==true && password_numbers !=true)
{
this.instruction = "Password Need 6-13 Characters With Numbers,Uppercase";
}
else if( password_caps!=true && password_splcase!=true && password_numbers==true )
{
this.instruction = "Password Need 6-13 Characters With Uppercase,Spl Characters";
}
else if( password_caps==true && password_splcase==true && password_numbers!=true )
{
this.instruction = "Password Need 6-13 Characters With Numbers";
}
else if( password_caps==true && password_splcase !=true && password_numbers==true )
{
this.instruction = "Password Need 6-13 Characters With Spl Characters";
}
else if( password_caps!=true && password_splcase==true && password_numbers==true )
{
this.instruction = "Password Need 6-13 Characters With Uppercase";
}
else if( password_caps==true && password_splcase==true && password_numbers==true )
{
this.instruction = "";
}
}
enter image description here
当用户给出大写字母时,删除指令中的大写单词,当给出特殊字符时,删除 spl 字符...,当字段为空时,显示旧指令。
<input type="password" (keyup)="error_message()" value='user_password'/>
<label>{{instruction}}</label>
error_message()
{
if(this.user_password=="")
{
this.instruction = "Password Need 6-13 Characters With Numbers,Uppercase,Spl Characters";
}
else
{
const regx = new RegExp("(?=.*?[A-Z])");
const Regx_speChar = new RegExp("(?=.*?[#?!@$%^&*-])");
const Regx_number = new RegExp("(?=.*?[0-9])");
const password_caps = this.user_password.match(regx)?true:false;
const password_splcase = this.user_password.match(Regx_speChar)?true:false;
const password_numbers = this.user_password.match(Regx_number)?true:false;
if( password_caps!=true && password_splcase!=true && password_numbers!=true)
{
this.instruction = "Password Need 6-13 Characters With Numbers,Uppercase,Spl Characters";
}
else if( password_caps==true && password_splcase !=true && password_numbers !=true )
{
this.instruction = "Password Need 6-13 Characters With Numbers,Spl Characters";
}
else if( password_caps!=true && password_splcase==true && password_numbers !=true)
{
this.instruction = "Password Need 6-13 Characters With Numbers,Uppercase";
}
else if( password_caps!=true && password_splcase!=true && password_numbers==true )
{
this.instruction = "Password Need 6-13 Characters With Uppercase,Spl Characters";
}
else if( password_caps==true && password_splcase==true && password_numbers!=true )
{
this.instruction = "Password Need 6-13 Characters With Numbers";
}
else if( password_caps==true && password_splcase !=true && password_numbers==true )
{
this.instruction = "Password Need 6-13 Characters With Spl Characters";
}
else if( password_caps!=true && password_splcase==true && password_numbers==true )
{
this.instruction = "Password Need 6-13 Characters With Uppercase";
}
else if( password_caps==true && password_splcase==true && password_numbers==true )
{
this.instruction = "";
}
}