Is there a way to force the TextBoxFor component to honour the data annotation string/max length for a model property?
I have the following model property with a data annotation for StringLength.
[Required]
[StringLength(5)]
[Display(Name = "Name")]
public string Name { get; set; }
I'm using the TextBoxFor component in a view. But it will NOT enforce the maximum string length during data entry.
In order to get the TextBoxFor to restrict the maximum string length, I have to add the @maxlength property myself.
@(Html.Kendo().TextBoxFor(m => m.Country.Name)
.HtmlAttributes(new { @maxlength = "5" })
)
Is there a way to have the TextBoxFor enforce the string length based on the data annotation itself?
Thanks.
Jason