title: Displaying Form Error Messages in a bootstraps modal
body: <p>I have a login form that is rendered in a template, i would like to display the error messages in case of submitting wrong results or wrong format in a bootstrap modal.</p>
  
  <pre><code>&lt;!--- modal start---&gt;
  &lt;div class="modal fade" id="loginform" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true"&gt;
    &lt;div class="modal-dialog" role="document"&gt;
      &lt;div class="modal-content"&gt;
        &lt;div class="modal-header modalheader"&gt;
          &lt;h5 class="modal-title" id="exampleModalLongTitle"&gt;Error&lt;/h5&gt;
          &lt;button type="button" class="close" data-dismiss="modal" aria-label="Close"&gt;
                                          &lt;span aria-hidden="true"&gt;&amp;times;&lt;/span&gt;
                                      &lt;/button&gt;
        &lt;/div&gt;
        &lt;div class="modal-body"&gt;
          &lt;span class='form-errors'&gt;
                                              {% for error in form.non_field_errors %}
                                                  &lt;li&gt;{{ error }}&lt;/li&gt;
                                              {% endfor %}
                                          &lt;/span&gt;
        &lt;/div&gt;
        &lt;div class="modal-footer"&gt;
          &lt;button type="submit" class="btn btn-success"&gt;Ok&lt;/button&gt;
          &lt;button type="button" class="btn btn-secondary" data-dismiss="modal"&gt;
                                                  Cancel
                                              &lt;/button&gt;
        &lt;/div&gt;
      &lt;/div&gt;
  
  
    &lt;/div&gt;
  
  
  &lt;/div&gt;
  &lt;!--- modal end----&gt;
  </code></pre>
  
  <p>this is the java script to trigger the modal</p>
  
  <pre><code>&lt;script&gt;$('#loginform').on('form-errors', function (e) {
      // Show the message modal
      $('#messageModal').modal('show');
  });&lt;/script&gt;
  </code></pre>