您的位置:首页 > Web前端 > JQuery

jquery判断用户名称是否存在

2010-06-13 13:31 633 查看
/// <reference path="../jquery-1.3.2-vsdoc.js" />
$(document).ready(function(){
checkConfirm();
});
//验证用户名是否存在
function checkConfirm() {
$("#TextBox_college_english_name").blur(function() {
var gradename = $(this).val();
var changeUrl = "../../handlers/cms/GetCollegeName.ashx?college_english_name=" + gradename;
$.get(changeUrl, function(str) {

if (str == '1') {
alert("已经存在英文名称为" + $("#TextBox_college_english_name").val() + "的院校,请查证!");
$("#TextBox_college_english_name").val("");
} else {
$("#gradeInfo").html("");
}
})
return false;
})
}

ashx页面代码

using System;
using System.Collections;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;

using Study.BLL.College_BLL;
namespace Study.Web.handlers.cms
{
/// <summary>
/// $codebehindclassname$ 的摘要说明
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class GetCollegeName : IHttpHandler
{

public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";

string username = context.Request.QueryString["college_english_name"].ToString();
BLL_College bll_college = new BLL_College();
DataTable dt = bll_college.GetCollegeEnglishName(username);
if (dt.Rows.Count > 0)
{
context.Response.Write("1");
}
else
{
context.Response.Write("0");
}

}

public bool IsReusable
{
get
{
return false;
}
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: