当前位置:K88软件开发文章中心编程语言AjaxAjax01 → 文章内容

ajax用户注册代码

减小字体 增大字体 作者:佚名     来源:asp编程网  发布时间:2018-12-30 9:22:31

终于实现了ajax用户注册系统.。注册界面如上。
index.html
<
!DOCTYPE 
HTML 
PUBLIC 
"
-//W3C//DTD 
HTML 
4.0 
Transitional//EN"
>

<
HTML>

 
<
HEAD>

 
 
<
TITLE>
 
用户注册 
<
/TITLE>

 
<
/HEAD>

 
<
style>

 
<
!--
 
body,td 

{font-size:12px
}
 
input
{
background-color: 

#ffffff
 

color: 

#000000
 

font-family: 
tahoma

 
font-size: 
12px
 
border: 
1px 

#cccccc 
double}
 
-->

 
<
/style>

 
<
BODY>

 
 
<
script 
language=javascript>

 
 
<
!--
 
 
function 
checkUserName()
 
 

{
 
 
 
username=this.form1.username.value

 
 
 
var 
xmlhttp

 
 
 
try
 
 
 

{
 
 
xmlhttp=new 
ActiveXObject("
Msxml2.XMLHTTP"
)

 
 
 
}
 
 
 
catch 
(e)
 
 
 

{
 
 
 
 
 
try
 
 
 
 
 

{
 
 
 
 
 
 
 
xmlhttp=new 
ActiveXObject("
Microsoft.XMLHTTP"
)

 
 
 
 
 
}
 
 
 
 
 
catch 
(e)
 
 
 
 
 



 
 
 
 
 
try
 
 
 
 
 

{
 
 
 
xmlhttp=new 
XMLHttpRequest()

 
 
 
 
 
}
 
 
 
 
 
catch 
(e)
 
 
 
 
 

{
 
 
 
 
 
}
 
 
 
 
 
}
 
 
 
}
 
 
if 
(username=="
"
)
 
 

{
 
 
 
 
msg="
用户名不能为空"


 
var 
ch=document.getElementById("
check1"
)

 
ch.innerHTML="
<
font 
color=&
#39

#aaaaaa&
#39
>
"
+msg+"
<
/font>
"

 
 
 
 

 
return 
false

 
 
}

 
 
//创建请求,并使用escape对username编码,以避免乱码
xmlhttp.open("
get"
,"
checkuser.asp?username="
+escape(username)+ 

"
&

#38
t="
 

 
new 
Date().getTime())

 
 
 
xmlhttp.onreadystatechange=function()
 
 
 

{
 
 
 
 
 
if(4==xmlhttp.readyState)
 
 

{
 
 
 
 
if(200==xmlhttp.status)
 
 
 
 

{
 
 
 
 
 
 
if 
(xmlhttp.responseText=="
yes"
)
 
 
 
 
 
 



 
 
 
 
 
msg="
此用户名已经存在"


 
 
 
 
 
 
}
 
 
 
else
 
 
 

{
 
 
 
 
msg="
输入正确"


 
 
 

 

 
 
 
 
}
 
 
 
 
else
 
 
 
 

{
 
 
 
 
 
 
msg="
网络链接失败"


 
 
 
 
}
 
 
 
 
var 
ch=document.getElementById("
check1"
)

 
 
 
 
ch.innerHTML="
<
font 
color=&
#39

#aaaaaa&
#39
>
"
+msg+"
<
/font>
"

 
 
 
 

 
 
}
 
 
 
}
 
 
 
xmlhttp.send(null)
 
 

 
 
 
return 
false

 
 
 

 

 
 
//-->

 
 
<
/script>


 
 
<
script 
language="
javascript"
>

 
 
function 
checkpass1()
 
 

{
 
 
 
 
var 
Inform="
form1"


 
var 
Inputname="
password1"


 
 
 
 
var 
Form=Inform+"
."

 
 
 
 
eval("
Temp="
+Form+Inputname+"
.value
"
)
 

 
//alert(Temp)

 
if(Temp=="
"
)


 
msg="
此项不能为空"

 

 
}
 
else
 


 

 
 
 
 
 
 
if(Temp.length<
6||Temp.length>
20)
 
 
 

{
 
 
 
 
 
msg="
密码必须在6~20个字符之间"


 
 
 
}
 
 
 
else
 
 
 

{
 
 
var 
Inputname1="
password"


 
 
 
 
 
eval("
Temp1="
+Form+Inputname1+"
.value"
)

 
 
if 
(Temp!=Temp1)
 
 

{
 
 
 
 
 
 
 
 
 
 
eval(Form+Inputname+"
.value=&
#39
&
#39

"
)

 
 
 
 
eval(Form+Inputname1+"
.value=&
#39
&
#39

"
)

 
 
 
 
eval(Form+Inputname1+"
.focus()
"
)

 
 
 
 
msg="
两次密码不一样!"

 

 
 
 
 
msg1="
"


 
 
 
 
var 
ch1=document.getElementById("
password2"
)

 
 
 
 
ch1.innerHTML="
<
font 
color=&
#39

#aaaaaa&
#39
>
"
+msg1+"
<
/font>
"


 
 
}
 
 
else
 
 

{
 
 
 
 
msg="
输入正确"


 
 
}
 
 
 
}
 
}
 
var 
ch=document.getElementById("
password3"
)

 
ch.innerHTML="
<
font 
color=&
#39

#aaaaaa&
#39
>
"
+msg+"
<
/font>
"

 

 
 
}
 
 
 
 
function 
checkpass()
 
 

{
 
 
 
 
var 
Inform="
form1"


 
var 
Inputname="
password"


 
 
 
 
var 
Form=Inform+"
."

 
 
 
 
eval("
Temp="
+Form+Inputname+"
.value
"
)
 

 
//alert(Temp)

 
if(Temp=="
"
)


 
msg="
此项不能为空"

 

 
}
 
else
 


 

 
 
 
 
 
 
if(Temp.length<
6||Temp.length>
20)
 
 
 

{
 
 
 
 
 
msg="
密码必须在6~20个字符之间"


 
 
 
}
 
 
 
e

[1] [2] [3]  下一页


ajax用户注册代码