MVC3DataAnnotations验证与自定义jQuery验证一起使用

MVC3DataAnnotations验证与自定义jQuery验证一起使用,jquery,asp.net-mvc,data-annotations,Jquery,Asp.net Mvc,Data Annotations,我有一个使用数据注释验证的MVC应用程序。我还需要提交一些手动jQuery验证。我希望在jQuery验证通过并且框架实现的不引人注目的验证通过时隐藏submit按钮 这是我的代码: $('#btnSubmit').click(function () { if (!$('#Terms').is(':checked')) { $('.termsLabel').animate({ color: "#c71040" }, 'slow'); $('.termsLab

我有一个使用数据注释验证的MVC应用程序。我还需要提交一些手动jQuery验证。我希望在jQuery验证通过并且框架实现的不引人注目的验证通过时隐藏submit按钮

这是我的代码:

$('#btnSubmit').click(function () {
    if (!$('#Terms').is(':checked')) {
        $('.termsLabel').animate({ color: "#c71040" }, 'slow');
        $('.termsLabel a').animate({ color: "#c71040" }, 'slow');
        return false;
    }

    if ($('.wordCount').hasClass('error')) {
        $('.caption label').animate({ color: "#c71040" }, 'slow');
        return false;
    }

    if ($(form).valid()) {
        $('#btnSubmit').hide();
        $('#submitting').show();
    }

});
(form).valid()方法似乎总是返回false(并且从不执行隐藏/显示),即使在表单发布时也是如此

我这么做的原因是我允许用户上传一张图片,我不希望用户能够点击不止一次


任何帮助-谢谢。

我会回答我自己的问题

表格上:

@using (Html.BeginForm("MyAction", "MyController", FormMethod.Post, new { @ID = "MyForm" }))
然后:

$('#MyForm').validate();

    if ($('#MyForm').valid()) {
        $('#btnSubmit').hide();
        $('#submitting').show();
    }
问题是我没有给表单命名,也没有调用.validate()

表单在哪里定义$(形式)似乎不正确。