title: Restrict time in jQuery timepicker dynamically?
body: <p>I am having two fields in my form. One is date field which is using jQuery date picker and another one is jQuery time picker. Now the problem is, if i select the today's date in the date field, then the time picker should not shows the past time. For eg. if the time now is 17:00 hrs, then the timepicker should not shows the time before 17:00 hrs as selectable. Here is my code,</p>
  
  <pre><code>$(function() {
      $( ".datepicker" ).datepicker({minDate:'0'});
      $('.timepicker').timepicker();
  });
  
  $("#date").click(function(){
      if($("#date").val()=='04/17/2012')
      {
          updatetimefortoday();
      }
  });![enter image description here][1]
  
  function updatetimefortoday()
  {
      $('.timepicker').timepicker({
          onHourShow: timepickerRestrictHours
      });
  
      function timepickerRestrictHours(hour)
      {
          if ((hour &gt; 17))
          {
              return true;
          }
          return false;
      }
  }
  </code></pre>
  
  <p>Now the problem is if we call the function <code>updatetimefortoday()</code> on <code>document.ready</code>, it is showing the timepicker correctly. But if we do it on click of the date field as shown in the code it is not working.</p>
  
  <p><img src="https://i.stack.imgur.com/O1tLg.png" alt="enter image description here"></p>
  
  <p>This is the expected output after selecting the date.</p>