Asp.net mvc 3 使用MVC3的jQuery验证问题

Asp.net mvc 3 使用MVC3的jQuery验证问题,asp.net-mvc-3,jquery-validate,Asp.net Mvc 3,Jquery Validate,我的问题是,我正在使用MVC3的不引人注目的客户端验证功能,但我需要与之挂钩,并添加一个函数,该函数在成功验证时启动,但在表单发布之前启动 我希望有一些预构建的助手或者一个简单的方法来连接到验证器 下面是一段代码片段: @using (Html.BeginForm("MyAction","MyController")) { @Html.ValidationSummary(true) <fieldset> <legend><le

我的问题是,我正在使用MVC3的不引人注目的客户端验证功能,但我需要与之挂钩,并添加一个函数,该函数在成功验证时启动,但在表单发布之前启动

我希望有一些预构建的助手或者一个简单的方法来连接到验证器

下面是一段代码片段:

    @using (Html.BeginForm("MyAction","MyController")) {
        @Html.ValidationSummary(true)
        <fieldset> <legend><legend>
        <label for="FirstName">First Name</label>
        @Html.TextBoxFor(model => model.FirstName)
        @Html.ValidationMessageFor(model => model.FirstName)
使用(Html.BeginForm(“MyAction”、“MyController”)){ @Html.ValidationSummary(true) 名字 @Html.TextBoxFor(model=>model.FirstName) @Html.ValidationMessageFor(model=>model.FirstName) 试试这些文章

希望这些能帮助你


谢谢

我最终需要连接到验证过程中来执行我自己的自定义验证,并进行一些div折叠。下面是jQuery的一个片段,它完成了我所需要的:

    //Hijack the submit event to do custom validation and collapse the div
    $('#theFormName').submit(function () {
        var customErrorHandling = false;

        //do some custom validation

        if (customerErrorHandling == false) {

            //Now do the jQuery validation
            if ($('#theFormName').valid()) {

                //do some div collapsing

                $('#theFormName').unbind('submit');
                $('#theFormName').submit();
            }
        }
        return false;
    });