title: MVC Validation - Updating another field?
body: <p>We are currently creating a couple of input fields which will contain a start and end datetime, one in each field. We have validation currently working so that it displays an error message if a user puts the start time after the end time (and vice verse for an end time before the start) however we have come across an interesting issue with this. </p>
  
  <p>If the user, for example, puts an end time before the start time, we get an error message on the end time as expected. </p>
  
  <p><a href="https://i.stack.imgur.com/t0jNm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/t0jNm.png" alt="enter image description here"></a></p>
  
  <p>However if the start date is then amended as opposed to the end date, the message remains.</p>
  
  <p><a href="https://i.stack.imgur.com/eZXT9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eZXT9.png" alt="enter image description here"></a></p>
  
  <p>Is there a way to remove/update/correct the validation message on a different field? Here's the code for the validation:</p>
  
  <pre><code>[Required(ErrorMessage = "{0} is required!")]
  [Display(Name = "Start Date")]
  [Remote("IsTestPlanEndCorrect", "Analysis", AdditionalFields = "EndDate", HttpMethod = "Post", ErrorMessage = "Test Plan Start Time must be before End.")]
  public System.DateTime StartDate { get; set; }
  
  [Required(ErrorMessage = "{0} is required!")]
  [Display(Name = "End Date")]
  [Remote("IsTestPlanEndCorrect", "Analysis", AdditionalFields = "StartDate", HttpMethod = "Post", ErrorMessage = "Test Plan End Time must be after Start.")]
  public System.DateTime EndDate { get; set; }
  </code></pre>
  
  <p><code>IsTestPlanEndCorrect</code> is simply a method which returns true or false depending if the passed data passes the validation.</p>
  
  <p>EDIT:
  Razor code for the fields:</p>
  
  <pre><code>&lt;div class="form-group"&gt;
  @Html.LabelFor(t =&gt; t.StartDate, new { @class = "col-md-2 control-label" })
  &lt;div class="col-md-10"&gt;
          @Html.TextBoxFor(t =&gt; t.StartDate, new { @class = "form-control datetimepicker", placeholder = "Enter Test Plan Start"})
          @Html.ValidationMessageFor(t =&gt; t.StartDate)
      &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;div class="form-group"&gt;
      @Html.LabelFor(t =&gt; t.EndDate, new { @class = "col-md-2 control-label" })
      &lt;div class="col-md-10"&gt;
          @Html.TextBoxFor(t =&gt; t.EndDate, new { @class = "form-control datetimepicker", placeholder = "Enter Test Plan End"})
          @Html.ValidationMessageFor(t =&gt; t.EndDate)
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Validation code in the controller:</p>
  
  <pre><code>[HttpPost]
  public JsonResult IsTestPlanEndCorrect(DateTime EndDate, DateTime StartDate )
  {
      return Json(TimeManipulation.checkDate(StartDate,EndDate));
  }
  </code></pre>