Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where is the right version of MicrosoftMvcJQueryValidation.js for MVC 2 beta 2?

MicrosoftMvcJQueryValidation.js is used by ASP.NET MVC 2 for client side validation.

Having problems with this file just not working properly and wondering if I have the wrong version.

The version I am using came from the source for futures.

 MicrosoftMvcJQueryValidation.js
 5,626 bytes
 11/17/09 10:43:12am

There are two reasons i think i have the wrong version :

1) I actually have to call this code to get the validation routine working at all. This is because the default client validation function now embedded into FormContext.cs is Sys.Mvc.FormValidation.enableClientValidation .

 ViewContext.FormContext.ClientValidationFunction = "EnableClientValidation";

2) There is some code from jquery.validate.js which does the followin :

  this.settings.errorPlacement
    ? this.settings.errorPlacement(label, $(element) )
    : label.insertAfter(element);

This calls into this function in MicrosoftMvcJQueryValidation.js :

 errorPlacement: function(error, element) {
        var messageSpan = fieldToMessageMappings[element.attr("name")];
        $(messageSpan).empty();
        $(messageSpan).removeClass("field-validation-valid");
        $(messageSpan).addClass("field-validation-error");
        error.removeClass("input-validation-error");
        error.attr("_for_validation_message", messageSpan);
        error.appendTo(messageSpan);
    },

The problem is that element has been wrapped by jQuery.validate with the jQuery $(element) expression.

Therefore element.attr("name") is undefined, but element[0].attr("name") is valid.

I've taken MicrosoftMvcJQueryValidation.js from the futures download on Microsoft's site. `

I cant find any other MicrosoftMvcJQueryValidation version - but I'm sure there must be one. Can anyone help?

like image 690
Simon_Weaver Avatar asked Dec 10 '09 01:12

Simon_Weaver


1 Answers

As of Dec 17, 2009 the latest version of MicrosoftMvcJQueryValidation.js is available in the futures download project.

Be careful to include MicrosoftMvcJQueryValidation.js and NOT the similarly named MicrosoftMvcValidation.js.

like image 96
Simon_Weaver Avatar answered Oct 10 '22 21:10

Simon_Weaver