title: How to check validation between two dates in datepicker
body: <p>I am using datepicker to get date, I need to do validation like if start date is greater than end date then need to display an error</p>
  
  <p>I have tried with below code, but it dint work</p>
  
  <pre><code>    $('body').on('focus', ".datepicker", function () {
          $(this).datepicker({
              autoclose: true,
              format: '&lt;?php echo date_format_datepicker(); ?&gt;',
              language: '&lt;?php _trans('cldr'); ?&gt;',
              weekStart: '&lt;?php echo get_setting('first_day_of_week'); ?&gt;',
              todayBtn: "linked"
          });
  
          var sDate;
          $("#product_start").datepicker().on('changeDate',function (ev) {
              sDate = $(this).val();
          });
  
  
          $("#product_end").datepicker().on('changeDate',function (ev) {
          var edate = $(this).val();
              if (sDate &gt; edate) {
                  // $('#edate').datepicker("setDate", sdate);
                  $('#date_error').append("Date should lesser than start date")
              }
  
      });
  </code></pre>
  
  <p>HTML code </p>
  
  <pre><code>//Start date 
  &lt;input name="product_start" id="product_start" class="form-control input-sm datepicker"&gt;
  
  //end date
  &lt;input name="product_end" id="product_start" class="form-control input-sm datepicker"&gt;
  </code></pre>
  
  <p>It prints prints error multiple times if start date greater than end date ..</p>