title: End-date greater than start-date validation javascript not working properly
body: <p>I am trying to make a validation for my dates so that enddate to be greater than start date but is not working.What am i doing wrong?   </p>
  
  <pre><code> &lt;head&gt;
   &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.min.js")" type="text/javascript"&gt;&lt;/script&gt;
    &lt;link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" /&gt;       
    &lt;script src="@Url.Content("~/Scripts/jquery-ui-1.8.19.min.js")" type="text/javascript"&gt;&lt;/script&gt;
    &lt;script src="@Url.Content("~/Scripts/jquery-ui.unobtrusive.min.js")" type="text/javascript"&gt;&lt;/script&gt;   
    &lt;script src="@Url.Content("~/Scripts/jquery-ui.unobtrusive-0.5.0.min.js")" type="text/javascript"&gt;&lt;/script&gt;
    &lt;script src="@Url.Content("~/Scripts/gen_validatorv4.js")" type="text/javascript"&gt;&lt;/script&gt;
  
    &lt;/head&gt;
       @using (Html.BeginForm("SearchFree", "Reservation", FormMethod.Get,new {id = "form" }))
     {                    
  
    &lt;h7&gt;Introduceti perioada Rezervarii&lt;/h7&gt;
  &lt;div class="editor-label"&gt;
  &lt;label id="cautare" for="StartDate"&gt;Data Intrare:   &lt;/label&gt;@(Html.JQueryUI().Datepicker("StartDate").DateFormat("mm-dd-yy").MinDate(DateTime.Today).ShowButtonPanel(true).ChangeYear(true).ChangeMonth(true).NumberOfMonths(2))
  &lt;/div&gt;
  &lt;div class="editor-label"&gt;
  &lt;label  id="cautare"  for="EndDate"&gt;Data Iesire:&lt;/label&gt;@(Html.JQueryUI().Datepicker("EndDate").DateFormat("mm-dd-yy").MinDate(DateTime.Today).ShowButtonPanel(true).ChangeYear(true).ChangeMonth(true).NumberOfMonths(2))
  
  &lt;/div&gt;
  
  &lt;p&gt;
      &lt;input id="buton1" type="submit" value="Cauta camere libere" /&gt;
  &lt;/p&gt;
  
        }
        &lt;script type="text/javascript"&gt;
           $(document).ready(function () {
      $.validator.addMethod("EndDate", function (value, element) {
          var startDate = $('.StartDate').val();
          return Date.parse(startDate) &lt;= Date.parse(value);
      }
        , "* End date must be after start date");
       $('.form').validate();
      });
        &lt;/script&gt;
  </code></pre>