$(document).ready(function(){
    $("#txt_name").blur(function(){
        $("#userExist").text("");
        if ($("#txt_name[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/RoleExist.aspx?Name="+$(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_name").focus();
            }
        })
    });
});

