title: Showing validation errors in a modal pop up in mvc view
body: <p>I have a main view in which I am calling a partial view 'Add'. This Add view is a form with a submit button and I am displaying it as a modal pop up box.
  To submit the form, I am making an ajax call to an action method. Now, I need two things-
  1. If data posted is valid, then display a success message and close the modal
  2. If there is any validation error, show them on the modal pop up while highlighting the fields.
   I am using twitter bootstrap for displaying the modal.
  Ajax call :</p>
  
  <pre><code> $.ajax({
          url: urlForSavingAdd,
          data: JSON.stringify(dataToSend),
          cache: false,
          type: 'POST',
          dataType: 'application/JSON',
          contentType: "application/json;charset=utf-8",
          success: function (data, status) {
                  $('#divAddNew').html(data.Message);
                  $('#divAddNew').fadeOut();
                  },
          error: function (xhr, ajaxOptions, thrownError) {
                 var errorMessage = xhr.responseText;
                 $('#divAddNew').html(errorMessage);
                $('#divAddNew').show();
          }
      });
  </code></pre>
  
  <p>Controller -</p>
  
  <pre><code>[HttpPost]
      public JsonResult Add(SomeModel add)
      {
          if (ModelState.IsValid)
          {
              //Save item to DB
                  return Json(new
                  {
                     Message = "Record saved successfully to the Database."
                  });
           }
          else
          {
                  return Json(new
                      {
                     Message = GetModelStateErrors(this.ModelState);
                       });
           }
      }
  </code></pre>