$(function () {

    //检查用户是否存在
    function isUserNameExist(name) {
        var retValue = false
        $.ajax({
            type: "POST",
            url: "Ajax/UserDispose.ashx",
            data: { 'com': 'isuserexist', 'username': name },
            datatype: "json",
            async: false,
            beforeSend: function (data, textStatus) { },
            success: function (data, textStatus) {
                if (data == "0") {
                    retValue = true;
                } else {
                    retValue = false;
                }
            },
            error: function (e) { alert("连接失败,请向Eoyoo官方技术人员反馈!"); }
        })
        return retValue;
    }

    //提交判断
    $("form").submit(function () {
        $("input[type='text'],input[type='password'],textarea").trigger("blur");
        $("select").trigger("change");

        ///新增方法填写在此///
        if ($("#userName_hide").val() != $("#userName_txt").val()) {
            if (!isUserNameExist($("#userName_txt").val())) {
                $("#userName_txt").next("span").attr("class", "point ico-error R");
                $("#userName_txt").next("span").html("帐户名已经存在,请更换个试试");
                return false;
            }
        }
        /////

        if ($("form span").hasClass("ico-error")) {
            $("input:submit").attr("disabled", false);
            $("input:submit").next("span").attr("class", "point ico-error R");
            $("input:submit").next("span").text("请按照提示正确操作，检查各项填写");
            setInterval(delSubmitBtnMsg, 3000);
            return false;
        } else {
            $("input:submit").attr("disabled", true);
            $("input:submit").next("span").attr("class", "Q");
            $("input:submit").next("span").html("<img src=\"Images/Loading.gif\" align=\"middle\" /> 正在保存…");
        }
    });

})