Reputation: 1421
I found many tutorials how to do custom client side validation with ASP.NET MVC 3 validation (example):
Sys.Mvc.ValidatorRegistry.validators["priceOnRange"] = function(rule) {
var minPrice = rule.ValidationParameters.minPrice;
var maxPrice = rule.ValidationParameters.maxPrice;
var message = rule.ErrorMessage;
return function (value, context) {
if (value > maxPrice || value < minPrice) {
return false;
}
return true;
};
};
this is module for validating price for custom DataAnnotation for PriceRange but how can i convert to jQuery plugin or call this with jQuery without referencing scripts from Microsoft.
Upvotes: 2
Views: 655
Reputation: 39501
In ASP.NET MVC 3, the more modern, unobtrusive style validation is used by default, which uses jQuery validation plugin, not the MicrosoftMvcValidation
. So, by default, in mvc3, you should not need to reference Microsoft scripts. Take a look at Brad Wilson's Presentation about custom unobtrusive validation. He covers number of topics there, including custom validation.
Upvotes: 2