title: How to dynamically add and remove maxlength validation by Parsley.js?
body: <p>I am using <a href="http://parsleyjs.org/" rel="nofollow noreferrer">parsley.js</a> and I have to dynamically show/hide validation according to the data the user has selected.</p>
  
  <p>I have read this <a href="https://stackoverflow.com/questions/21867162/how-can-i-dynamically-add-and-remove-form-fields-to-be-validated-by-parsley-js/21885466#21885466">SO post</a> to dynamically add or remove required fields to be validated by parsley, which was helpful.</p>
  
  <p><strong>But how do I dynamically remove and add the <em>maxlength</em> for an input field?</strong></p>
  
  <p>I have tried the following two options:</p>
  
  <pre><code>$('input').attr('data-parsley-maxlength', 'true');
  $('input').attr('data-parsley-maxlength', true);
  </code></pre>
  
  <p>But the above gives the following error message:</p>
  
  <pre><code>This value is too long. It should have true characters or fewer.
  </code></pre>