<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="PasswordStrong._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<input id="reg_passwd__" name="reg_passwd__" value="" ;="" onkeyup="update_strength('reg_passwd__','reg_passwd__strength_display__')" autocomplete="off" type="password"/>
<script type="text/javascript">
function update_strength(input_field_id, output_display_id)
{
var input_field = document.getElementById(input_field_id);
var output_display = document.getElementById(output_display_id);
var input_str = input_field.value;
var input_length = input_str.length;
var strength = 0;
// increase strength if contains [0-9]
number_re = new RegExp("[0-9]");
if (number_re.test(input_str)) {
strength++;
}
// increase strength if contains non alpha
non_alpha_re = new RegExp("[^A-Za-z0-9]");
if (non_alpha_re.test(input_str)) {
strength++;
}
// increase strength if contains upper case
upper_alpha_re = new RegExp("[A-Z]");
if (upper_alpha_re.test(input_str)) {
strength++;
}
// increase strength if long enough
if(input_length >=8) {
strength++;
}
var strength_str;
if (strength <= 1) {
strength_str = '<strong style="color:blue">弱</strong>';
} else if (strength <= 2) {
strength_str = '<strong style="color:blue">中等</strong>';
} else {
strength_str = '<strong style="color:green">强壮</strong>';
}
if(input_str.length < 6) {
strength_str = '<strong style="color:orange">太弱</strong>';
}
output_display.innerHTML = strength_str;
}
</script>
<div>
<span>密码强度: </span>
<span id="reg_passwd__strength_display__">
</span>
</div>
</div>
</form>
</body>
</html>
Word教程网 | Excel教程网 | Dreamweaver教程网 | Fireworks教程网 | PPT教程网 | FLASH教程网 | PS教程网 |
HTML教程网 | DIV CSS教程网 | FLASH AS教程网 | ACCESS教程网 | SQL SERVER教程网 | C语言教程网 | JAVASCRIPT教程网 |
ASP教程网 | ASP.NET教程网 | CorelDraw教程网 |