I use jquery validate unobtrusive in the Asp.Net MVC 5 project. And validation works in English, but I want it in other language, Norwegian for instance.
I found messages_no.js here https://github.com/jzaefferer/jquery-validation/tree/master/src/localization and included that js file after jquery.validate.js and jquery.validate.unobtrusive.js. I can see in developer tools that it is included in page properly but error messages are still in English.
Am I missing something?
The error messsage are retrieved from html attributes(data-val-) of controls.
Controls are generated server side (Html.EditorFor), using the DataAnnotations of the property.
So for example instead of
[Required(ErrorMessage = "Required")]
public string Email { get; set; }
you should use resources (.resx files)
[Required(ErrorMessageResourceType = typeof(Resource), ErrorMessageResourceName = "Required"]
public string Email { get; set; }
Make sure Thread.CurrentThread.CurrentCulture and Thread.CurrentThread.CurrentUICulture are set in the desired culture.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With