title: MVC client side error message not showing
body: <p>I want to implement client side validation on my form, but none of the error message is showing when I put the wrong data.  Below is my model code:</p>
  
  <p>Model:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  using System.ComponentModel.DataAnnotations;
  
  namespace LayoutProject.Models
  {
      public class Book
      {
          public int BookId { get; set; }
          [Required]
          public String Title { get; set; }
          public String Author { get; set; }
      }
  }
  </code></pre>
  
  <p>My partial view:</p>
  
  <pre><code>@model LayoutProject.Models.Book    
  
  &lt;h4&gt;Books&lt;/h4&gt;
  
  @Html.ValidationSummary(true, "", new { @class = "text-danger" })
  
      &lt;table&gt;
          &lt;tr&gt;
              &lt;td&gt;@Html.LabelFor(d=&gt;d.BookId)&lt;/td&gt;
              &lt;td&gt;@Html.TextBoxFor(d=&gt;d.BookId)&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;@Html.LabelFor(d=&gt;d.Title)&lt;/td&gt;
              &lt;td&gt;@Html.TextBoxFor(d=&gt;d.Title)
                  @{ Html.ValidateFor(d =&gt; d.Title); }
                  @Html.ValidationMessageFor(d=&gt;d.Title, "", new { @class = "text-danger" })
              &lt;/td&gt;
  
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;@Html.LabelFor(d=&gt;d.Author)&lt;/td&gt;
              &lt;td&gt;@Html.TextBoxFor(d=&gt;d.Author)&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/table&gt;
  </code></pre>
  
  <p>View:</p>
  
  <pre><code>    @{
      ViewBag.Title = "CreateBooks";
  }
  
  &lt;h2&gt;CreateBooks&lt;/h2&gt;
  
  &lt;form action="/Home/SaveBooks" method="post"&gt;
      @Html.Partial("_CreateBook")
      &lt;input id="createBook" type="submit" value="Submit"/&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>My controller:</p>
  
  <pre><code>[HttpPost]
  public ActionResult SaveBooks(Book book)
  {
      if (ModelState.IsValid)
      {
  
          //write code to update student 
  
          return RedirectToAction("Index");
      }
      return View(book);
  }
  </code></pre>
  
  <p>I have added the required scripts in my layout: validate and unobtrusive scripts.  But whenever, I submit the form, with the Title field empty, which is a required field, it goes in the controller and no error message is displayed.  Any idea what might cause this error?</p>
  
  <p>Do I need to add all this scripts too:   </p>
  
  <pre><code>  &lt;script src="@Url.Content("~/Scripts/jquery-1.5.1.js")" type="text/javascript"&gt;&lt;/script&gt;
  &lt;script src="@Url.Content("~/Scripts/jquery-ui-1.8.11.js")" type="text/javascript"&gt;&lt;/script&gt;
  &lt;script src="../../Scripts/jquery-1.5.1-vsdoc.js" type="text/javascript"&gt;&lt;/script&gt;
  &lt;script src="../../Scripts/jquery.validate-vsdoc.js" type="text/javascript"&gt;&lt;/script&gt;
  &lt;script src="@Url.Content("/Scripts/jquery.unobtrusive-ajax.js")" type="text/javascript"&gt;&lt;/script&gt;
  &lt;script src="@Url.Content("~/Scripts/jquery.validate.js")" type="text/javascript"&gt;&lt;/script&gt;
  &lt;script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.js")" type="text/javascript"&gt;&lt;/script&gt;
  </code></pre>