1000hz / bootstrap-validator

A user-friendly HTML5 form validation jQuery plugin for Bootstrap 3
http://1000hz.github.io/bootstrap-validator
MIT License
2.38k stars 1.07k forks source link

How to exclude validation for those field which is inside hidden Div #632

Open frensrazer opened 6 years ago

frensrazer commented 6 years ago

I couldnot able to findout solution so please give me some idea how to troubleshoot this issue. Here is the sample even i added "required" attribute in checkbox that is no visible for guest so only when it's visible validation should work else it shouldnot be.

<form data-toggle="validator" role="form" id="testform">
  <div class="form-group">
    <label for="inputName" class="control-label">Name</label>
    <input type="text" class="form-control" id="inputName" placeholder="Cina Saffary" required>
  </div>

<div class="hiddenDiv">
  <div class="form-group ">
    <div class="checkbox">
      <label>
        <input type="checkbox" id="terms" data-error="Before you wreck yourself" required>
        Check yourself
      </label>
      <div class="help-block with-errors"></div>
    </div>
  </div>
</div>

<div class="form-group">
    <button type="submit" class="btn btn-primary">Submit</button>
  </div>
</form>
ishafayshahid commented 4 years ago

Simply you can hide your input by css .hiddenDiv input { display:none; } Error will show but input will be hidden and you can also use bootstrap hidden class to do this.