How to validate jQuery UI Date Picker "From Date" to "To Date"
<p>I have 2 fields "From date" and "To date". I am new in jQuery and I am learning it. </p>

<ol>
<li>When selecting from date on jQuery UI Date Picker, all previous
dates (before current date) to be un-selectable (greyed out).</li>
<li>When selecting to date, only dates starting from current date

<ul>
<li>1 day to be selectable (cannot select same from date or date passed as to date)</li>
</ul></li>
</ol>

<p><strong>I am currently using this code:</strong></p>

<pre><code>$( function() {
var dateFormat = "dd-mm-yy",
  from = $( "#from" )
    .datepicker({
      defaultDate: "+1w",
      changeMonth: true,
      numberOfMonths: 3
    })
    .on( "change", function() {
      to.datepicker( "option", "minDate", getDate( this ) );
    }),
  to = $( "#to" ).datepicker({
    defaultDate: "+1w",
    changeMonth: true,
    numberOfMonths: 3
  })
  .on( "change", function() {
    from.datepicker( "option", "maxDate", getDate( this ) );
  });

function getDate( element ) {
  var date;
  try {
    date = $.datepicker.parseDate( dateFormat, element.value );
  } catch( error ) {
    date = null;
  }

  return date;
}
});
</code></pre>

<p><strong>Note:</strong> Date format should be "<strong>dd-mm-yy</strong>"</p>