bootstrap-validator icon indicating copy to clipboard operation
bootstrap-validator copied to clipboard

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

Open frensrazer opened this issue 6 years ago • 1 comments

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>

frensrazer avatar Aug 01 '18 07:08 frensrazer

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.

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

<div class="form-group">
    <button type="submit" class="btn btn-primary">Submit</button>
</div>

ishafayshahid avatar Nov 17 '19 12:11 ishafayshahid