I'm using MVC3's Razor engine to generate views and have the following line of code generating a textbox
@Html.EditorFor(model => model.AddressLine1)
In the relevant model I'm using a data annotation attribute to limit the number of acceptable characters to 55:
[StringLength(55)]
public string AddressLine1 { get; set; }
However this allows the user to type in a longer address only to be then told via a validation message when they try and submit the form. How can I limit the textbox to 55 characters so that the user is unable to type any more than that in?
If I was generating the text box myself I would use the maxlength attribute for an input type but I'm not sure how to achieve the same results using the Html.EditFor method.