title: How to use html.ValidationMessageFor
body: <p>I'm trying to get my view to give me the error message next to the text box if a user enters something invalid (like a string where it's expecting a number).  Instead, I'm getting an ugly error page saying validation failed when the user presses submit.</p>
  
  <p>Here is a portion of my view:</p>
  
  <pre><code>@model MembershipTest.ViewModels.AddDriverViewModel
  
  &lt;script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"&gt;&lt;/script&gt;
  &lt;script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"&gt;&lt;/script&gt;
  
  @{
  Layout = "~/Views/Shared/_Layout.cshtml";
  ViewBag.Title = "Add Drivers";
  }
  
  @using (Html.BeginForm("AddDriver", "Driver"))
  {
  @Html.AntiForgeryToken()
  @Html.ValidationSummary(true)
  
  &lt;fieldset&gt;
  &lt;legend&gt;Customer Information&lt;/legend&gt;
   &lt;table&gt;
       &lt;tr&gt;
           &lt;td&gt;
               @Html.Label("First Name:")
               @Html.TextBoxFor(m =&gt; m.Driver.F_Name)
               @Html.ValidationMessageFor(m =&gt; m.Driver.F_Name)
           &lt;/td&gt;
           &lt;td&gt;
               @Html.Label("Gender:")
  
               @Html.RadioButtonFor(m =&gt; m.isMaleChecked, "true") Male
               @Html.RadioButtonFor(m =&gt; m.isMaleChecked, "false")Female
           &lt;/td&gt;
       &lt;/tr&gt;
       &lt;tr&gt;
           &lt;td&gt;
               @Html.Label("Last Name:")
               @Html.TextBoxFor(m =&gt; m.Driver.L_Name)
               @Html.ValidationMessageFor(m =&gt; m.Driver.L_Name)
           &lt;/td&gt;
  </code></pre>
  
  <p>And here is the relevant portion of my model:</p>
  
  <pre><code>[Required]
  [StringLength(30)]
  public string F_Name { get; set; }
  
  [Required]
  [StringLength(30)]
  public string L_Name { get; set; }
  </code></pre>
  
  <p>In the post method of my controller, I make sure to use</p>
  
  <pre><code>if (ModelState.IsValid)
  </code></pre>
  
  <p>If the user happened to enter something like 50 characters long in the first name text box, I want an error to be displayed using the Html.ValidationMessageFor() right when they tab out of that text box, so they can see it before they press submit.  Am I missing some jquery to make this happen?  Maybe some using statement I need to include?</p>