-->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>
<title>用户名校验实例</title>
<script src="../js/jquery-1.7.2.js" type="text/javascript"></script>
<script src="../js/verify.js" type="text/javascript"></script>
</head>
<body onload="verify()">
用户名校验的jax实例
<>
<input type="text" value="" id="userName" />
<input type="button" value="提交"/>
<>
<div id="result"></div>
<->
</body>
</html>
—>js页
复制代码 代码如下:
function verify() {
$("#userName").keyup(function () {
var user = $(this).val();
var userobj = $(this);
$.post("../index.aspx", { userobj: user }, callback);
});
}
function callback(data) {
$("#result").text(data);
}
—>aspx页
复制代码 代码如下:
<%
Response.Clear();
string str_name = Request["userobj"];
if (str_name == "xtyang")
{
Response.Write("ok");
}
else
{
Response.Write("no");
}
Response.End();
%>