$(function () {
    function ValidTemp() {
        var APIUser = $("#APIUser"),
        APIPassWord = $("#APIPassWord"),
        APIEmail = $("#APIEmail"),
        allFields = $([])
                .add(APIUser)
                .add(APIPassWord)
                .add(APIEmail)
        ;
        var bValid = true;
        allFields.removeClass("ui-state-error");
        bValid = bValid && checkLength(APIUser, "接口帐号", 1, 255);
        bValid = bValid && checkLength(APIPassWord, "接口密码", 0, 128);
        bValid = bValid && checkLength(APIEmail, "接口EMAIL", 0, 255);
        return bValid;
    };
    $("form").submit(function () {
        if (!ValidTemp()) {
            $(this).find("button[type=submit]").removeClass("loading").removeAttr("disabled");
            return false;
        }
    });
});