title: How to set datepicker on select change?
body: <p>I have a very simple problem. But I am unable to resolve the issue.</p>
  
  <p>I want to set datepicker to a input on select change. Also on changing the select to other option the datepicker should be removed and only textbox should be displayed.</p>
  
  <p>This is what I have tried so far</p>
  
  <pre><code>jQuery(document).ready(function(){
  
                      jQuery('#filevalidity').change(function(){
                          var option = jQuery(this).find("option:selected").val();
                          if(option === "MAX_DOWNLOAD_LIMIT")
                          {
  
                              jQuery('#dlorex').next('input').datepicker("destroy");
                          }
                          if(option === "EXPIRY_DATE")
                          {
  
                              jQuery('#dlorex').next('input').datepicker({minDate : 1});
                          }
                      });
  
                  });
  </code></pre>
  
  <p><strong><a href="http://jsfiddle.net/Kunalh/ktjsyfg0/" rel="nofollow">Here is the fiddle</a></strong></p>
  
  <p>Where am I going wrong?</p>