Given a ViewModel that looks like this:
public class Login {
[Required]
public string Username { get; set; }
[Required, CustomValidator]
public string Password { get; set; }
}
And a View like this (Razor syntax here):
@Html.TextBoxFor(f => f.Password)
I am getting the following markup:
<input type="text"
value=""
data-val-required="This field is required." />
However I would like it to also include a 'data-' attribute for my custom validator.
I want something like this:
<input type="text"
value=""
data-val-required="This field is required."
data-val-customvalidator="XYZ" />
How can I achieve this with ASP.NET MVC 3.0?
E.g. Do I need to put some special attribute on my custom validator? Or register it somewhere?