密码的强弱提示是对用户填写登陆密码的复杂程度来给出提示,使用密码的强弱提示可以增强用户对密码的保护意识,对如今的网络是非常有必要的,本程序中当用户输入完密码后,网页会自动的对用户输入的密码给出强弱判断。

密码强弱提示(27)

使用JavaScript脚本来判断用户输入的密码位数是否大于6位,如果小于六位将设置单元格“弱”的背景颜色,否则设置“强”的单元格背景颜色,JavaScript的代码如下:

<script>
function passHint()
{
var txt=document.getElementById('txtPass').value;
if(txt.length<6)
{
document.all("tab").row[0].cells[1].bgColor="red";
document.all("tab").row[0].cells[2].bgColor=" ";
}
else
{
document.all("tab").row[0].cells[2].bgColor="red";
document.all("tab").row[0].cells[1].bgColor="";
}
}
</script>

 

在输入密码文本框中的onChange的事件中将调用JavaScript中的passHint函数,来判断用户添加的密码强度并给出提示。onChange事件将会在用户填写完密码选择其他控件时引发。密码文本框的前台代码:

<asp:TextBox ID="txtPass" runat="server" onchange="passHint()" TextMode="Password" Width="66px"></asp;TexBox>

相关文章:

  • 2021-04-19
  • 2021-09-08
  • 2021-09-01
  • 2021-06-13
  • 2022-12-23
  • 2021-08-21
  • 2021-09-16
  • 2021-11-05
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案