title: How to toggle bootstrap DatePicker by setting readonly attribute?
body: <p>I tried to set <code>datepicker</code> to be enable or disable <code>datepicker</code> according first selection. If user select option "Applied", I would like to set <code>readonly</code> attribute to field <code>datepicker</code> and not allow it to be popup calendar.</p>
  
  <p>My sample below produce two fields: Application Selection and DatePicker Fields:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$(document).ready(function(){
      $('#NextFollowDate').datepicker({
          format:"yyyy-mm-dd"
      });
      $('#ActivityType').on('change',function()
      {
          var actType = $(this).val();
          if (actType=='3')
          {
              $('#NextFollowDate').attr('readonly','readonly');
          }
          else
          {
              $('#NextFollowDate').removeAttr('readonly');
          }
      });
  })</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.7.1/css/bootstrap-datepicker.css"&gt;
  &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.7.1/js/bootstrap-datepicker.js"&gt;&lt;/script&gt;
  
  &lt;select class="form-control" id="ActivityType" name="ActivityType"&gt;
      &lt;option selected="" value="__None"&gt;--None--&lt;/option&gt;
      &lt;option value="1"&gt;1 - First Appoinment&lt;/option&gt;
      &lt;option value="2"&gt;2 - Second Appoinment&lt;/option&gt;
      &lt;option value="3"&gt;3 - Applied&lt;/option&gt;
  &lt;/select&gt;
  &lt;div class="form-group"&gt;
      &lt;label for="NextFollowDate" class="col-sm-2 control-label"&gt;&lt;label for="NextFollowDate"&gt;Next Date&lt;/label&gt;&lt;/label&gt;
      &lt;div class="col-sm-10"&gt;
          &lt;input class="form-control" id="NextFollowDate" name="NextFollowDate" type="text" value="" style="width: 214px;"&gt;
      &lt;/div&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>From <code>readonly</code> attribute does not stop <code>DatePicker</code> field from popup at all. Yet, setting <code>$('#NextFollowDate').attr('disabled','disabled');</code>, it would working fine. However, it is problematic when I submitted the form; therefore, I would like it to be <code>readonly</code> and prevent calendar from pop up.</p>
  
  <p>Is there any way that I can archived that with <code>readonly</code> attribute? Thanks.</p>