$(function () {
    function ValidTemp() {

        var BoxName = $("#BoxName"),
        Power = $("#Power"),
        Memo = $("#Memo")
        allFields = $([])
        .add(BoxName)
        .add(Power)
        .add(Memo)
        ;
        var bValid = true;
        allFields.removeClass("ui-state-error");
        bValid = bValid && checkLength(BoxName, "机箱名称", 1, 50);
        bValid = bValid && checkLength(Power, "电源保证", 1, 50);
        return bValid;
    };
    $("form").submit(function () {
        if (!ValidTemp()) {
            $(this).find("button[type=submit]").removeClass("loading").removeAttr("disabled");
            return false;
        }
    });
});