title: Limiting the length of characters in a textbox while using Razor's Html.EditFor
body: <p>I'm using MVC3's Razor engine to generate views and have the following line of code generating a textbox</p>
  
  <pre><code> @Html.EditorFor(model =&gt; model.AddressLine1)
  </code></pre>
  
  <p>In the relevant model I'm using a data annotation attribute to limit the number of acceptable characters to 55:</p>
  
  <pre><code>[StringLength(55)]
  public string  AddressLine1 { get; set; }
  </code></pre>
  
  <p>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? </p>
  
  <p>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.</p>