Currently utilizing Bootstrap version 5.3.3, I have the following structure established to create a large checkbox:
.form-check-input[type=checkbox].big-checkbox {
transform: scale(3);
margin: 1.5rem;
border-radius: 0;
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="23414c4c57505751425363160d100d10">[email protected]</a>/dist/css/bootstrap.min.css" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
<!-- Table and checkbox inside it without validation -->
<table>
<tr>
<td>
<input type="checkbox" id="exampleOne" name="exampleOne"
class="form-check-input big-checkbox"
checked
>
</td>
<td>
<label class="form-check-label" for="exampleOne">
This checkbox does not have validation
</label>
</td>
</tr>
</table>
<!-- Turn this into table with same layout and working validation feedback -->
<form id="form" novalidate>
<div class="form-check mt-4 mb-3">
<input type="checkbox" id="exampleTwo" name="exampleTwo"
class="form-check-input big-checkbox"
required
>
<label class="form-check-label" for="exampleTwo">
This checkbox has validation
<a href="#" data-bs-toggle="modal"
data-bs-target="#universalModal"
data-modal-id="testModal"
class="test-link"
>
Test link
</a>
</label>
<div class="invalid-feedback">I am a red invalid feedback text.</div>
</div>
</form>
In order to make the lower checkbox function similarly to the upper one while incorporating Bootstrap's form validation, adjustments need to be made. Utilizing a table layout like below:
<table>
<tr>
<td>
<input type="checkbox" id="exampleTwo" name="exampleTwo"
class="form-check-input big-checkbox"
required
>
</td>
<td>
<label class="form-check-label" for="exampleTwo">
This checkbox has validation
<a href="#" data-bs-toggle="modal" data-bs-target="#universalModal"
data-modal-id="testModal" class="test-link"
>
Test link
</a>
</label>
<div class="invalid-feedback">
I am a red invalid feedback text.
</div>
</td>
</tr>
</table>
When the large checkbox is invalid, it visually changes color but the label remains unchanged, and the invalid-feedback message does not display. The reason for this discrepancy is due to the separation of the input field, label, and feedback message within different cells of the table.
To ensure proper form validation functionality, all elements should ideally reside within the same parent element. Applying the 'big-checkbox' class in a non-table format can also cause appearance issues.
If you encountered this scenario, how would you address it to maintain consistent form validation behavior as expected within the Bootstrap framework?