title: parsley.js - disable the maxlength validation
body: <p>I am trying to dynamically disable the parsley.js max length on several of my input fields when the user makes a selection on a select list on the form.</p>
  
  <p><strong>I have read this <a href="https://stackoverflow.com/questions/25458470/how-to-dynamically-add-and-remove-maxlength-validation-by-parsley-js">thread</a>, but when I put the code into my field, the parsley is not triggered, instead the form submits, and I do not understand why.</strong></p>
  
  <p>I have read the parsley.js docs, but I am unable to see why the parsley.js validation is ignored when i add the following line of code:</p>
  
  <pre><code>$('#id_employment_record_position_title').attr('data-parsley-maxlength', '0');
  </code></pre>
  
  <p>or </p>
  
  <pre><code>$('#id_employment_record_position_title').attr('data-parsley-maxlength', '150');
  </code></pre>
  
  <p>This is my code to dynamically turm the parsley validation on and off when the user changes the select list on the form:</p>
  
  <pre><code>function toggleFormDetails() {
  
      if ( $('#id_employment_record_display_type').val() == '8888' || $('#id_employment_record_display_type').val() == '9999' ) {
  
          //disable the input field.        
          $('#id_employment_record_position_title').prop('disabled', true); 
          ....
  
          //destroy parsley on the form.
          //$('#employment_history_details_form').parsley().destroy();
  
          //disable the parsley maxlength, when the input field is disabled.
          $('#id_employment_record_position_title').attr('data-parsley-maxlength', '0');
  
          //reinitialise parsley on the form.
          //$('#employment_history_details_form').parsley();
  
      } else {
  
          //enable the input field.
          $('#id_employment_record_position_title').prop('disabled', false);
          ....
  
          //destroy parsley on the form.
          //$('#employment_history_details_form').parsley().destroy();
  
          //change the parsley cs error values for all the required form inputs.
          $('#id_employment_record_position_title').attr('data-parsley-maxlength', '150');
  
          //reinitialise parsley on the form.
          //$('#employment_history_details_form').parsley();
  
      }
  
  }
  </code></pre>
  
  <p>Why do I have have to add the destroy &amp; create parsley code on the form (I have commented them out above)?</p>
  
  <p>Would it be better to write a custom validation for this? If so, how would I do that, b/c my js code skills are not yet good enough?</p>