title: Ajax.BeginForm and validation
body: <p>Client side validation is not working for me in Ajax.BeginForm </p>
  
  <p>This is my code:</p>
  
  <pre><code>&lt;div id="report"&gt;
      &lt;div id="projectReport"&gt;
          &lt;div &gt;
              @{
                  Html.EnableClientValidation();
              }
  
              @using (Ajax.BeginForm("AnalyticsDates", new AjaxOptions
                  {
                      InsertionMode = InsertionMode.Replace,
                      UpdateTargetId = "reportContent"
                  }))
              {
                  @Html.LabelFor(m =&gt; m.StartDate)
                  @Html.TextBoxFor(m =&gt; m.StartDate, new { id = "start" })
                  @Html.ValidationMessageFor(model =&gt; model.StartDate)
                  @Html.LabelFor(m =&gt; m.EndDate)
                  @Html.TextBoxFor(m =&gt; m.EndDate, new { id = "end" })
                  @Html.ValidationMessageFor(model =&gt; model.EndDate)
                  &lt;input id="btnsearch" type="submit" value=@Titles.Search class="iconHeader"/&gt;
              }
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;div id="reportContent"&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>And I enabled validation in the web.config page:    </p>
  
  <pre><code>&lt;add key="ClientValidationEnabled" value="true" /&gt;   
  &lt;add key="UnobtrusiveJavaScriptEnabled" value="true" /&gt;
  </code></pre>
  
  <p>and added js files as well</p>
  
  <pre><code>&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.js")" type="text/javascript"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>second issue related to the first one,
  my action is </p>
  
  <pre><code>[HttpPost]
          [Authorize(Roles = "XXXReport")]
          public async Task&lt;ActionResult&gt; AnalyticsDates(ReportRequestVM reportRequestVM)
          {
              if (!ModelState.IsValid)
              {
                  return View("**MainReports**", reportRequestVM);
              }
  
              // fill reportRequestVM with data
              return View("**PartialReport**", reportRequestVM);
  
  
          }
  </code></pre>
  
  <p>If the model is valid I return a partial view and the page looks fine , otherwise I return the main view , with the form , but in this the page renders it self twice. the question is, in case the client validation fails,how to return the main form with the validation errors ?</p>
  
  <p>Any help would be appreciated, 
  10x Rony</p>