$(document).ready(function(){
    $("#txt_LoginName").blur(function(){
        $("#userExist").text("");
        if ($("#txt_LoginName[readonly]").size()>0) {
            return;
        }
        if($(this).val()=="")
        {
            return;
        }
        $("#userExist").css({"background-image":"url(../images/indicator.gif)", "background-repeat":"no-repeat","width":"15px","height":"15px"});
        $.get("../Ajax/UserExist.aspx?loginName="+$(this).val()+"&"+Math.random(),function(data){
            if(data=="0")
            {
                $("#userExist").css({"width":"auto","height":"auto","background-image":"","color":"green"});
                $("#userExist").text("这个帐号可以使用！");
            }
            else if(data=="1")
            {
                $("#userExist").css({"width":"auto","height":"auto","background-image":"","color":"red"});
                $("#userExist").text("这个帐号已经存在，请重新输入帐号！");
                $("#txt_LoginName").focus();
            }
            else if (data=="tooLong") {
                $("#userExist").css({"width":"auto","height":"auto","background-image":"","color":"red"});
                $("#userExist").text("用户名太长！");
                $("#txt_LoginName").focus();
            }
            else if (data=="tooShort") {
                $("#userExist").css({"width":"auto","height":"auto","background-image":"","color":"red"});
                $("#userExist").text("用户名太短！");
                $("#txt_LoginName").focus();
            }
            else if (data=="nameForb") {
                $("#userExist").css({"width":"auto","height":"auto","background-image":"","color":"red"});
                $("#userExist").text("您不能取这个名字，请重新选一个！");
                $("#txt_LoginName").focus();
            }
            
        })
    });
});