title: MVC3 Validation: Change element class when invalid
body: <p>I'm using server validation and want to change the element class when invalid.
  So for example I have a textbox with a validationmessage:</p>
  
  <pre><code>@Html.ValidationMessageFor(m =&gt; m.FirstName, new {@class = "error"})
  @Html.TextBoxFor(m =&gt; m.FirstName, new {@class = "aftererror"})
  </code></pre>
  
  <p>When the textbox data is invalid I want the textbox to get a red border.
  I tried to change it using css selectors:</p>
  
  <pre><code> .error + .aftererror
      {   
          border:solid 1px red;
          }
  </code></pre>
  
  <p>so when the validationmessage is showing, the textbox would get the "aftererror" class.
  Unfortunately the validation element is also showing even if the data is valid, only there is no text.</p>
  
  <p>So how would I change the css class of the texbox on error, or have the validation element disappear when there's no error.</p>