title: bootstrapValidator: How do you add and remove validators dynamically to an existing input field?
body: <p>I have a dynamic form that is bound with <code>knockout.js</code> and validated by <code>bootstrapValidator</code>.</p>
  
  <p>There is one input field that needs to be 'required-validated' dependent on the state of another control.</p>
  
  <p>The input field:</p>
  
  <pre><code>&lt;textarea id="inputReason" name="inputReason" rows="3" 
            class="form-control col-lg-8"
            data-bind="value: Reason" /&gt;
  </code></pre>
  
  <p>The relevant javascript part of the knockout-viewmodel:</p>
  
  <pre><code>self.SelectAbsenceType = function (absenceType) {
      self.SelectedID(absenceType.ID);
  
      if (self.SelectedAbsenceType().ReasonRequired) {
          $('#formCreate').bootstrapValidator('addField', 'inputReason', {
              validators: {
                  notEmpty: {
                      message: 'Please enter a reason'
                  }
              }
          });
      } else {
          $('#formCreate').bootstrapValidator('removeField', 'inputReason');
      }
  }
  </code></pre>
  
  <p>The problem I'm facing is that a call to <code>removeField</code> of the <code>bootstrapValidator</code> instance doesnt seem to completely remove all registration infos since there is a javascript exception in the <code>updateStatus</code> method of the <code>bootstrapValidator</code> class that in fact should not be called at all since I have the removed the field before:</p>
  
  <pre><code>var that  = this,
      type  = fields.attr('type'),
      group = this.options.fields[field].group || this.options.group,
      total = ('radio' === type || 'checkbox' === type) ? 1 : fields.length;
  </code></pre>
  
  <p><strong>The exception</strong>: Unable to get value of the property 'group': object is null or undefined</p>
  
  <p>The variable <code>field</code> contains the value 'inputReason'.</p>
  
  <p>So my Question is this (because the documentation of bootstrapValidators <code>removeField</code> is not entirely clear on this: How do I remove the dynamically added validation of the field inputReason completey?</p>
  
  <p>(side note: can someone add the tag boostrapvalidator?)</p>