title: bootstrapvalidator one of two fields required
body: <p>I have a two phone fields on my form - phone and phone2. Only one of them is required. I have been unable to get the validation to work no matter what I have tried. I have tried callbacks and custom validators and it seems like I just can't get it to work. The way I would like it to work is check each field and if both are empty then display a custom message under each. If either one, or both, has data then go ahead and validate each for correctness. If/when the user clicks submit again, check both fields again and if either or both has status message, remove the message start validation on both all over again. I just cant' seem to get this to work and I don't know if it is as easy as somehow forcing the plugin to revalidate all (or custom selected) fields every time the submit button is hit or what. </p>
  
  <p>Hopefully this makes sense. If not please ask for more detail. I've been struggling with this for a while now and have cotton head.</p>
  
  <p>Basically, one of the two fields needs to have data and that data needs to be valid.</p>
  
  <p>I've seen the post on stackoverflow here: <a href="https://stackoverflow.com/questions/21878595/conditional-validation-with-bootstrapvalidator">Conditional validation with BootstrapValidator</a> but it looks like the answer was for a different plugin.</p>
  
  <p>Here is what I have been trying:</p>
  
  <pre><code>.bootstrapValidator({
      live: 'disabled',
      message: 'This value is not valid',
      fields: {
          phone: {
              group: '.col-md-3',
              validators: {
                  callback: {
                      callback: function(value, validator, $field) {
                          field_name = $($field).attr('name');
                          if (value.length == 0 &amp;&amp; $('#phone2').val() == '') {
                              return {
                                  valid: false,
                                  message: 'at least one phone number is required'
                              }
                          }
                          else
                          {
                              if ( $('#phone2') == '' )
                              {
                                  $('#defaultForm')
                                          .bootstrapValidator('resetField', $('#phone2') )
                                          //.bootstrapValidator('updateStatus', $('#phone2'), 'NOT_VALIDATED')
                                          ;
                              }
                          }
                          value = value.replace(/\D/g, '');
                          if ( value != '' ) {
                              if ( !((/^(?:(1\-?)|(\+1 ?))?\(?(\d{3})[\)\-\.]?(\d{3})[\-\.]?(\d{4})$/).test(value) &amp;&amp; (value.length == 10)) ) {
                                  //alert("PHONE DID NOT PASS VALIDATION");
                                  return {
                                      valid: false,
                                      message: 'Phone number is not valid'
                                  }
                              }
                              else
                              {
                                  return true;    
                              }
                          }
                          else
                          {
                              $('#defaultForm')
                                      .bootstrapValidator('resetField', field_name )
                                      .bootstrapValidator('updateStatus', field_name, 'NOT_VALIDATED')
                                      ;
                              return true;
                          }
                      }
                  }
              }
          },
          phone2: {
              group: '.col-md-3',
              validators: {
                  callback: {
                      callback: function(value, validator, $field) {
                          field_name = $($field).attr('name');
                          if (value.length == 0 &amp;&amp; $('#phone').val() == '') {
                              return {
                                  valid: false,
                                  message: 'at least one phone number is required'
                              }
                          }
                          else
                          {
                              if ( $('#phone') == '' )
                              {
                                  $('#defaultForm')
                                          .bootstrapValidator('resetField', $('#phone') )
                                          //.bootstrapValidator('updateStatus', $('#phone'), 'NOT_VALIDATED')
                                          ;
                              }
                          }
  
                          value = value.replace(/\D/g, '');
                          if ( value != '' ) {
                              if ( !((/^(?:(1\-?)|(\+1 ?))?\(?(\d{3})[\)\-\.]?(\d{3})[\-\.]?(\d{4})$/).test(value) &amp;&amp; (value.length == 10)) ) {
                                  //alert("PHONE2 DID NOT PASS VALIDATION");
                                  return {
                                      valid: false,
                                      message: 'Phone number2 is not valid'
                                  }
                              }
                              else
                              {
                                  return true;    
                              }
                          }
                          else
                          {
                              $('#defaultForm')
                                      .bootstrapValidator('resetField', field_name )
                                      .bootstrapValidator('updateStatus', field_name, 'NOT_VALIDATED')
                                      ;
                              return true;
                          }
                      }
                  }
              }
          }
      }
  })
  </code></pre>