title: Hiding a form-group with Flask Jinja2 and WTForms
body: <p>I'm trying to show or hide a form field based on the state of a checkbox in another part of the form. I thought that I could do this with jQuery .show() or .hide() with relative ease, but I'm not having much luck so far. Any thoughts?</p>
  
  <p>The form class:</p>
  
  <pre><code>class MyForm(Form):
      checked = BooleanField('Check this box:')
      date = DateField('Date:', format='%Y-%m-%d', id="dates")
      submit = SubmitField('Submit')
  </code></pre>
  
  <p>The template:</p>
  
  <pre><code>{% import "bootstrap/wtf.html" as wtf %}
  
  {% block content %}
  
  {{ form.hidden_tag() }}
  {{ wtf.form_field(form.checked) }}
  {{ wtf.form_field(form.date) }}
  {{ wtf.form_field(form.submit) }}
  
  {% endblock %}
  
  {% block scripts %}
  
  &lt;script type="text/javascript"&gt;
  jQuery(document).ready(function() {
    $("#checked").change(function() {
      if(this.checked) {
          $('#dates').show();
      } else {
        $('#dates').hide();
      }
    });
  });
  &lt;/script&gt;
  
  {% endblock %}
  </code></pre>