标签:
<script src="js/jquery-1.8.3.min.js"></script>
<script type="text/javascript">
$(function () {
$(‘#txtName‘).blur(function () {
var name = $(this).val();
if (name != "") {
$.post("CheckUserName.ashx", { "name": name }, function (data) {
$(‘#errorMsg‘).text(data);
});
} else {
$(‘#errorMsg‘).text("用户名不能为空");
}
});
});
</script>
<body>
<form id="form1" runat="server">
<div>
用户名:<input name="txtName" id="txtName" /><span id="errorMsg"></span><br />
密码:<input name="txtPwd" /><br />
<input type="submit" value="注册"/>
</div>
</form>
</body>
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
string name = context.Request["name"];
UserInfoBLL bll = new UserInfoBLL();
UserInfo userInfo = bll.GetOneUserInfoModel(name);
if(userInfo!=null)
{
context.Response.Write("用户名已存在");
}
else
{
context.Response.Write("用户名可用");
}
}
标签:
原文地址:http://www.cnblogs.com/bidianqing/p/4207354.html