title: Parsley JS add class to form
body: <p>I'm using Parsley v2, and I want to put all my errors in a div at the end of my form, instead of inline.</p>
  
  <p>I'm doing this by adding <code>data-parsley-errors-container="#error-container"</code> to the <code>form</code>, which works.</p>
  
  <p>However, if I style this, it's constantly visible. I want to hide it depending on whether the form is valid or not.</p>
  
  <p>I want to be able to add a <code>has-errors</code> class to the <code>form</code> tag whenever the valid status changes.</p>
  
  <p>Parsley 2 has a pubsub and listener feature instead of using callbacks and options. I'm not even sure of where to begin.</p>
  
  <p>I can do</p>
  
  <pre><code>$.listen('parsley:form:validated', function(e){
    e.$element.toggleClass('error', !e.validationResult);
  });
  </code></pre>
  
  <p>which works, but it doesn't update as I type in the fields.</p>
  
  <p>Listening for the <code>parsley:field:validated</code> event doesn't give me a way to see the form's validation status, as far as I can tell.</p>