检验密码强度的代码
这里不能上传压缩包,比较不爽,只能把几个文件放上来了。
第一个是显示的页面。Untitled-1.html
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<link rel="stylesheet" type="text/css" href="WEBBlue1033.css"/>
<script type="text/javascript" src="pswdplc.js"></script>
</head>

<body>
<form name="RegProfileForm" style="margin:0px;" method="POST" target="_self" onsubmit="return OnSubmit(this);">
Password:
<input name="p3e8" type="password" id="id3e8_9" maxlength="16" autocomplete="off" value="" style="ime-mode:disabled" class="css0081" onkeyup="javascript:SetPwdStrengthEx(document.forms[0],this.value);" /><br/>
<script type="text/javascript">
function DispPwdStrength(iN,sHL)

{ if(iN>3)
{ iN=3;}for(var i=0;i<4;i++)
{ var sHCR="css0162";if(i<=iN)
{ sHCR=sHL;}if(i>0)
{ GEId("idSM"+i).className=sHCR;}GEId("idSMT"+i).style.display=((i==iN)?"inline":"none");}}
</script>
<table cellpadding="0" cellspacing="0" class="css0161" style="height:19px"><tr><td id="idSM1" width="33%" class="css0162" align="center"><span style="font-size:1px"> </span><span id="idSMT1" style="display:none;">弱</span></td><td id="idSM2" width="34%" class="css0162" align="center" style="border-left:solid 1px #fff"><span style="font-size:1px"> </span><span id="idSMT0" style="display:inline;font-weight:normal;color:#666">Not rated</span><span id="idSMT2" style="display:none;">中</span></td><td id="idSM3" width="33%" class="css0162" align="center" style="border-left:solid 1px #fff"><span style="font-size:1px"> </span><span id="idSMT3" style="display:none;">强</span></td></tr></table>

</body>
</html>
第二个是JS文件,pswdplc.js
var kNoCanonicalCounterpart = 0;
var kCapitalLetter = 0;
var kSmallLetter = 1;
var kDigit = 2;
var kPunctuation = 3;
var kAlpha = 4;
var kCanonicalizeLettersOnly = true;
var kCananicalizeEverything = false;
var gDebugOutput = null;
var kDebugTraceLevelNone = 0;
var kDebugTraceLevelSuperDetail = 120;
var kDebugTraceLevelRealDetail = 100;
var kDebugTraceLevelAll = 80;
var kDebugTraceLevelMost = 60;
var kDebugTraceLevelFew = 40;
var kDebugTraceLevelRare = 20;
var gDebugTraceLevel = kDebugTraceLevelNone;
function DebugPrint()

{
var string = "";
if (gDebugTraceLevel && gDebugOutput &&
DebugPrint.arguments && (DebugPrint.arguments.length > 1) && (DebugPrint.arguments[0] <= gDebugTraceLevel))

{
for(var index = 1; index < DebugPrint.arguments.length; index++)

{
string += DebugPrint.arguments[index] + " ";
}
string += "<br>/n";
gDebugOutput(string);
}
}
function CSimilarityMap()

{
this.m_elements = "";
this.m_canonicalCounterparts = "";
}
function SimilarityMap_Add(element, canonicalCounterpart)

{
this.m_elements += element;
this.m_canonicalCounterparts += canonicalCounterpart;
}
function SimilarityMap_Lookup(element)

{
var canonicalCounterpart = kNoCanonicalCounterpart;
var index = this.m_elements.indexOf(element);
if (index >= 0)

{
canonicalCounterpart = this.m_canonicalCounterparts.charAt(index);
}
else

{
}
return canonicalCounterpart;
}
function SimilarityMap_GetCount()

{
return this.m_elements.length;
}
CSimilarityMap.prototype.Add = SimilarityMap_Add;
CSimilarityMap.prototype.Lookup = SimilarityMap_Lookup;
CSimilarityMap.prototype.GetCount = SimilarityMap_GetCount;
function CDictionaryEntry(length, wordList)

{
this.m_length = length;
this.m_wordList = wordList;
}
function DictionaryEntry_Lookup(strWord)

{
var fFound = false;
if (strWord.length == this.m_length)

{
var nFirst = 0;
var nLast = this.m_wordList.length - 1;
while( nFirst <= nLast )

{
var nCurrent = Math.floor((nFirst + nLast)/2);
if( strWord == this.m_wordList[nCurrent])

{
fFound = true;
break;
}
else if ( strWord > this.m_wordList[nCurrent])

{
nLast = nCurrent - 1;
}
else

{
nFirst = nCurrent + 1;
}
}
}

return fFound;
}
CDictionaryEntry.prototype.Lookup = DictionaryEntry_Lookup;
function CDictionary()

{
this.m_entries = new Array()
}
function Dictionary_Lookup(strWord)

{
for (var index = 0; index < this.m_entries.length; index++)

{
if (this.m_entries[index].Lookup(strWord))

{
return true;
}
}
}
function Dictionary_Add(length, wordList)

{
var iL=this.m_entries.length;
var cD=new CDictionaryEntry(length, wordList)
this.m_entries[iL]=cD;
}
CDictionary.prototype.Lookup = Dictionary_Lookup;
CDictionary.prototype.Add = Dictionary_Add;
var gSimilarityMap = new CSimilarityMap();
var gDictionary = new CDictionary();
function CharacterSetChecks(type, fResult)

{
this.type = type;
this.fResult = fResult;
}
function isctype(character, type, nDebugLevel)

{
var fResult = false;
switch(type)

{
case kCapitalLetter:
if((character >= "A") && (character <= "Z"))

{
fResult = true;
}
break;
case kSmallLetter:
if ((character >= "a") && (character <= "z"))

{
fResult = true;
}
break;
case kDigit:
if ((character >= "0") && (character <= "9"))

{
fResult = true;
}
break;
case kPunctuation:
if ("!@#$%^&*()_+-="/";:[
{]}/|.>,</?`~".indexOf(character) >= 0)

{
fResult = true;
}
break;
case kAlpha:
if (isctype(character, kCapitalLetter) || isctype(character, kSmallLetter))

{
fResult = true;
}
break;
default:
break;
}

return fResult;
}
function CanonicalizeWord(strWord, similarityMap, fLettersOnly)

{
var canonicalCounterpart = kNoCanonicalCounterpart;
var strCanonicalizedWord = "";
var nStringLength = 0;
if ((strWord != null) && (strWord.length > 0))

{
strCanonicalizedWord = strWord;
strCanonicalizedWord = strCanonicalizedWord.toLowerCase();

if (similarityMap.GetCount() > 0)

{
nStringLength = strCanonicalizedWord.length;

for(var index = 0; index < nStringLength; index++)

{
if (fLettersOnly && !isctype(strCanonicalizedWord.charAt(index), kSmallLetter, kDebugTraceLevelSuperDetail))

{
continue;
}

canonicalCounterpart = similarityMap.Lookup(strCanonicalizedWord.charAt(index));
if (canonicalCounterpart != kNoCanonicalCounterpart)

{
strCanonicalizedWord = strCanonicalizedWord.substring(0, index) + canonicalCounterpart +
strCanonicalizedWord.substring(index + 1, nStringLength);
}
}
}
}
return strCanonicaliz
第一个是显示的页面。Untitled-1.html



























第二个是JS文件,pswdplc.js








































































































































































































































声明:该文观点仅代表作者本人,入门客AI创业平台信息发布平台仅提供信息存储空间服务,如有疑问请联系rumenke@qq.com。
- 上一篇:没有了
- 下一篇:没有了