用JS编写输入用户名和密码

JavaScript026

用JS编写输入用户名和密码,第1张

var name=document.getElementById("username")var pwd=document.getElementById("usepwd")/*按钮点击事件*/if(name.value!=admin &&ped.value!=123456){alert("用户名或者密码错误")}else{alert("用户登陆成功")}---------------纯手打,望采纳

脚本说明:

第一步:把如下代码加入<head>区域中

<SCRIPT LANGUAGE="JavaScript">

<!-- Hide

al="`1234567890-=~!@#$%^&*()_+qwer"

+"tyuiop[]QWERTYUIOP{}|asdfghjklA"

+"SDFGHJKL:zxcvbnm,./ZXCVBNM<>?"

ab1=""

bctr=0

function ckPwd(){

tst=document.isn.username.value

+"*"+document.isn.passwrd.value+"*"

ls=document.pd.pe.value

a=eval(ls.substring(0,2))-91

ls=ls.substring(2,ls.length)

nls=""

flg=0

while (ls.length>12){

ab=eval(ls.substring(0,2))-89

ab1=(ab1==""?""+ab:ab1)

oab1=ab1

ls=ls.substring(2,ls.length)

for (var i=0i<abi++){

nr=eval(ls.substring(0,2))-a

ls=ls.substring(2,ls.length)

nls+=al.charAt(nr)

}

nls+="*"

if (nls.indexOf(tst)>-1){

ls=""

flg=1

}

}

if (flg==1){

tstOk()

}

else{

bctr++

if (bctr>3){

location.href="nopass.htm"

}

else{

alert("对不起,用户名/密码错误."

+" 你已试登录"+bctr+"次.")

}

}

}

function tstOk(){

ab1=ab1+""+a

alert("正确,开始登录!")

location.href="pwds.htm?"+ab1

}

// End Hiding -->

</SCRIPT>

第二步:把如下代码加入<body>区域中

<FORM NAME="pd">

<!-- Paste the element from the pseudo-encrypter here -->

<!-- Paste this element into your script -->

<INPUT TYPE='hidden' NAME='pe' VALUE='9393693658789606190557772053938953313395586858685868976834793758313033975834793758313033 '>

</FORM>

<FORM NAME="isn">

<TABLE BORDER=2 CELLPADDING=5 CELLSPACING=0 BGCOLOR=BLUE>

<TR><TD COLSPAN=2 ALIGN=CENTER><FONT SIZE=4 COLOR=WHITE FACE="楷体_GB2312"><B>请您输入</B></FONT></TD></TR>

<TR><TD><FONT SIZE=3 COLOR=WHITE><B>UserName:</B></FONT></TD>

<TD><INPUT TYPE="text" NAME="username" VALUE="" SIZE=10></TD></TR>

<TR><TD><FONT SIZE=3 COLOR=WHITE><B>Password:</B></FONT></TD>

<TD><INPUT TYPE="password" NAME="passwrd" VALUE="" SIZE=10></TD></TR>

<TR><TD COLSPAN=2 ALIGN=CENTER><INPUT TYPE="button" NAME="btn" VALUE=" 登录 " onClick="ckPwd()return false"></TD></TR>

</TABLE></FORM>

<TABLE BORDER=1 WIDTH=486>

<TR><TD COLSPAN=3 ALIGN=CENTER><FONT FACE="楷体_GB2312"><B>你可以使用如下号码:</B></FONT></TD</TR>

<TR><TD><FONT FACE="helvetica,arial,geneva">User Name:John<BR>Password: 4$3gb%a</TD>

<TD><FONT FACE="helvetica,arial,geneva">User Name: Mary<BR>Password: hHhHhH</TD>

<TD><FONT FACE="helvetica,arial,geneva">User Name: Humphrey<BR>Password: humphrey</TD></TR>

</TABLE>