$(function () {
    function ValidTemp() {
        var CPUName = $("#CPUName"),
        zhupin = $("#zhupin"),
        zongxian = $("#zongxian"),
        yiji = $("#yiji"),
        erji = $("#erji"),
        hexinNum = $("#hexinNum"),
        Memo = $("#Memo")
        allFields = $([])
        .add(CPUName)
        .add(zhupin)
        .add(zongxian)
        .add(yiji)
        .add(erji)
        .add(hexinNum)
        .add(Memo)
        ;
        var bValid = true;
        allFields.removeClass("ui-state-error");
        bValid = bValid && checkLength(CPUName, "CPU名称", 1, 50);
        bValid = bValid && checkLength(zhupin, "CPU主频", 1, 50);
        bValid = bValid && checkLength(zongxian, "前端总线", 1, 50);
        bValid = bValid && checkLength(yiji, "一级缓存", 1, 50);
        bValid = bValid && checkLength(erji, "二级缓存", 1, 50);
        bValid = bValid && checkLength(hexinNum, "核心数", 1, 50);
        return bValid;
    };
    $("form").submit(function () {
        if (!ValidTemp()) {
            $(this).find("button[type=submit]").removeClass("loading").removeAttr("disabled");
            return false;
        }
    });
});