Localizing jQuery client-side validation messages in ASP.net MVC

I use jquery for client side validation along with data annotations. Everything works fine, but I would like to localize the message when a numeric value is entered into a numeric text field. For server-side validation, this can be done by setting DefaultModelBinder.ResourceClassKey to the name of the resource class and providing a value for the PropertyValueInvalid key.

However, for checking on the client side, asp.net mvc uses its own resource file with the key 'ClientDataTypeModelValidatorProvider_FieldMustBeNumeric'. The only way to solve this problem is described in the Client-side validator and client-side validator in MVC 2 using jQuery.validate . The solution really works, but I was wondering if there is an easier or more correct way to do this.

Thank.

+5
source share
1 answer

Perhaps a more elegant way is to rewrite the class System.Web.Mvc.ClientDataTypeModelValidatorProviderand replace it in the collection ModelValidatorProviders.Providers.

. http://jwwishart.blogspot.com/2011/03/custom-server-and-client-side-required.html.

+1

All Articles