Phper-zero
php zend js css
PHP博客
::
首页
::
新随笔
::
联系
::
聚合
::
管理
posts - 12, comments - 0, trackbacks - 0
<
2008年7月
>
日
一
二
三
四
五
六
29
30
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1
2
3
4
5
6
7
8
9
留言簿
(4)
给我留言
查看公开留言
查看私人留言
随笔分类
Framework
linux(2)
Php(4)
Script(6)
Style
随笔档案
2008年7月 (5)
2008年6月 (7)
搜索
最新评论
阅读排行榜
1. Ubuntu软件包管理命令(2065)
2. js禁用复制,粘贴,选择,剪切(1776)
3. Apache2.2+php5+mysql+phpmyadmin(1557)
4. 多选框的提交(801)
5. 建议使用PDO连接数据库(793)
评论排行榜
1. Apache2.2+php5+mysql+phpmyadmin(0)
2. PHP的类型(0)
3. 建议使用PDO连接数据库(0)
4. 多选框的提交(0)
5. 调色板(0)
ajax
var
xmlHttp;
function
createXMLHttpRequest()
{
if
(window.ActiveXObject)
{
xmlHttp
=
new
ActiveXObject(
"
Microsoft.XMLHTTP
"
);
}
else
if
(window.XMLHttpRequest)
{
xmlHttp
=
new
XMLHttpRequest();
}
}
function
checkaccount()
{
var
account
=
document.register.account.value;
if
(account.length
<
5
)
{
document.getElementById(
"
account01
"
).innerHTML
=
"
5~20字の半角英数字
"
;
return
false
;
}
else
{
document.getElementById(
"
account01
"
).innerHTML
=
""
;
}
createXMLHttpRequest();
xmlHttp.onreadystatechange
=
handleAddStateChange;
xmlHttp.open(
"
POST
"
,
"
check.php
"
,
true
);
xmlHttp.setRequestHeader( 'Content
-
Type', 'application
/
x
-
www
-
form
-
urlencoded');
xmlHttp.send(
"
account=
"
+
document.register.account.value);
}
function
handleAddStateChange()
{
if
(xmlHttp.readyState
==
4
)
{
if
(xmlHttp.status
==
200
)
{
var
responseText
=
xmlHttp.responseText;
if
(responseText
==
"
1
"
)
{
document.getElementById(
"
account01
"
).innerHTML
=
"
ユーザーの名重複する
"
;
return
false
;
}
else
{
document.getElementById(
"
account01
"
).innerHTML
=
""
;
}
}
else
{
alert(
"
Error.
"
);
}
}
}
checkaccount.js
xmlHttp.open("POST", "check.php", true);这里的true为异步,flase为同步
<?
php
include
'
ChinaBS.php
'
;
$chinabs
=
new
ChinaBS();
$bs
=
$chinabs
->
queryAll(
$_POST
[
'
account
'
]);
$status
=
"
0
"
;
if
(
$bs
!=
null
) {
$status
=
"
1
"
;
}
else
{
$status
=
"
0
"
;
}
echo
$status
;
?>
check.php
<
input
type
="text"
id
="account"
name
="account"
size
="20"
maxlength
="20"
tabindex
="1"
onblur
="checkaccount()"
/>
<
font
color
="red"
><
span
id
="account01"
></
span
></
font
>
test.php
posted on 2008-07-22 08:53
Jarry
阅读(123)
评论(0)
编辑
收藏
引用
网摘
所属分类:
Script
只有注册用户
登录
后才能发表评论。
网站导航:
IT新闻
博客园
BlogJava
博客生活
IT博客网
C++博客
程序员招聘