form-check-inline and invalid-feedback rendering issue
See original GitHub issueThis is a valid way to render inline inputs. In order to show invalid feedback we need to cram it on the last container there or it will be display: none
. Obviously it renders like hell. (can’t get JS bin to work, sorry)
<div class="form-check form-check-inline">
<input class="form-check-input is-invalid" type="checkbox" value="x" name="user[test][]" id="user_test_x" />
<label class="form-check-label" for="user_test_x">X</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input is-invalid" type="checkbox" value="y" name="user[test][]" id="user_test_y" />
<label class="form-check-label" for="user_test_y">Y</label>
<div class="invalid-feedback">is invalid</div>
</div>
I don’t have a solution, just providing an example.
For server-side validations it’s easy to override css and add display: block
for invalid-feedback
.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:5
- Comments:8 (2 by maintainers)
Top Results From Across the Web
Display invalid-feedback text for radio button group in ...
Wrap the radio buttons in a form-group; Wrap the invalid-feedback inside the last of the form-check classes. // Example starter ...
Read more >Validation · Bootstrap v5.2
Provide valuable, actionable feedback to your users with HTML5 form ... HTML form validation is applied via CSS's two pseudo-classes, :invalid and :valid...
Read more >Validation · Boosted v5.0
When attempting to submit, you'll see the :invalid and :valid styles applied to your form controls. Custom feedback styles apply custom colors, borders,...
Read more >How To Validate HTML 5 Form Elements In Bootstrap 4
{valid|invalid}-tooltip classes to display validation feedback in a styled tooltip. Be sure to have a parent with position: relative on it for ...
Read more >How to Display Validation Message for Radio Buttons with ...
Approach 1: First wrap Radio buttons and its label by using form-check-inline class. Then add img tag within the above wrap after label...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
If anyone is interested in one solution, I ended up using some javascript in the form validation,
if (!$("input:radio[name='multipleradiobuttonsetname']").is(":checked")) { $("#idforinvalidsmessage").css("display", "block"); } form.classList.add('was-validated');
and also at the bottom of the page,
`<script>
$(document).ready(function(){
});
</script>`
Not exactly elegant, but at least now the invalid feedback can be placed anywhere on the page and outside a radio div.
As long as invalid feedback is generated by the server. You can just add this css rule and everything should render acceptably: