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?