title: Date validation on search input/textbox for a razor view MVC
body: <p>I would like to add a textbox (date) and button to my report, which filters the data.  </p>
  
  <p>The below mvc is working, but the input must still be validated (must be a DATE) on client side (and server side if possible)</p>
  
  <p>My Model looks like this :</p>
  
  <pre><code>public class DailyReport
  {    
      public int DailyReportID { get; set; }
      public DateTime? ReportDate { get; set; }
  }
  </code></pre>
  
  <p>View : </p>
  
  <pre><code>@model IEnumerable&lt;project_name.Models.DailyReport&gt;
  @* text box and button:  *@
  @using (Html.BeginForm("Index", "DailyReport", FormMethod.Get))
  {   &lt;p&gt;
       Title: @Html.TextBox("SearchDateString")
       &lt;input type="submit" value="Filter" /&gt;
       &lt;/p&gt;
  }
  @* display dates*@
  @foreach (var item in Model)
  {       @Html.DisplayFor(modelItem =&gt; item.ReportDate)
  }
  </code></pre>
  
  <p>my controller:</p>
  
  <pre><code>   public ViewResult Index(String SearchDateString)
      {
          var dailyreport = db.DailyReport.Include(d =&gt; d.Site);
  
          if (!String.IsNullOrEmpty(SearchDateString))
          {
              DateTime search_date = Convert.ToDateTime(SearchDateString);
              dailyreport = dailyreport.Where(r =&gt; r.ReportDate == search_date);
          }
          return View(dailyreport.ToList());
      }
  </code></pre>
  
  <p>Can someone help me please? 
  How do I make sure a valid date is entered in the textbox?
  Should I create a another model with a date field for this input? </p>