I'm trying to get unobtrusive client-side validation working within an Orchard module, but i've hit a problem.
In this example i'm just trying to enforce the RequiredAttribute on a textbox field, using Html.TextBoxFor().
It looks to me as though the custom ModelValidatorProvider implemented by Orchard (LocalizedModelValidatorProvider) prevents the HTML5 input attributes from being rendered, specifically:
data-val
data-val-required
for the standard DataAnnotations RequiredAttribute. These attributes are required by jQuery.validate.unobtrusive to work.
The LocalizedModelValidatorProvider maps a RequiredAttribute to a LocalizedRequiredAttribute, so perhaps this a bug (or unimplemented feature) in the Orchard ViewEngine when rendering a textbox input for a model property decorated with a LocalizedRequiredAttribute?
I suspect that somehow this isn't happening:
tagBuilder.MergeAttributes(htmlHelper.GetUnobtrusiveValidationAttributes(name, metadata));
(from System.Web.Mvc.Html.InputExtensions)
I'm currently running Orchard 1.3.9.
Note: A hacky workaround is to remove the registration of the LocalizedModelValidatorProvider in the OrchardStarter module and default back to the standard MVC 3 provider, although i'm keen not to disturb the Orchard source if at all possible (not to mention i might need localized messages at some point)...