Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JQuery 1.6 $('form').validate() not working in IE7 & IE8

UPDATE: I've created a new MVC 3 project with Razor HTML 5, then I've updated the project with NuGet at JQuery 1.6 and the validation plugin doesn't work any more, it does a post back every time and returns the error message from server. I think the validation plugin is broken with JQuery 1.6

I have a MVC 3 app that uses Jquery UI dialog (loaded from a partial view that contains a form) in order to submit information over ajax to the server. I want to trigger the validation of my form on the client side before I do the ajax post. On Firefox and IE9 works fine, in IE7 & IE8 the form.validate() always returns true.

Here is the js code attached to my submit button:

    var wizard = $("#wizard"); //div that holds the modal dialog
    var myform = $("#wizard form");

    var submitFunction = function (e) {
        e.preventDefault(); //no postback
        myform.validate();
        if (myform.valid()) {
            $(this).attr("disabled", "disabled");
            submited = true;
            $.post(
                "SuperAdmin/CreateEditController",
                $(this).serialize(),
                function (data) {
                    if (data.Success) {
                        wizard.dialog('destroy');
                    }
                    else {
                        wizard.html(data.Html);
                    }
                },
                "json"
            ); //end json post
        }
    };
myform.submit(submitFunction);

I am using the following includes:

<script src="@Url.Content("~/Scripts/jquery-1.6.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.js")" type="text/javascript"></script>

The JQuery Validation plugin was upgraded with NuGet at version 1.8.0 and JQuery library to 1.6.

Update: I've tested the code generated with scaffolding default template and it does the same thing, no client side validation. Maybe JQuery 1.6 is not compatible with the Razor scaffolding template ??

like image 754
Stefan P. Avatar asked May 06 '11 09:05

Stefan P.


1 Answers

Jquery Validate does not currently work with jQuery 1.6 in IE6, IE7, and IE8.

https://github.com/jzaefferer/jquery-validation/issues/105

like image 181
SickHippie Avatar answered Oct 13 '22 16:10

SickHippie