question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

form-check-inline and invalid-feedback rendering issue

See original GitHub issue

This 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.

Demo: https://codepen.io/anon/pen/vdGNWo

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:5
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
mlindberg2commented, Sep 27, 2018

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(){

$("input:radio[name='multipleradiobuttonsetname']").click(function(){
    $("#idforinvalidsmessage").css("display", "none");
	
});

});

</script>`

Not exactly elegant, but at least now the invalid feedback can be placed anywhere on the page and outside a radio div.

1reaction
GBHcommented, Sep 27, 2018

As long as invalid feedback is generated by the server. You can just add this css rule and everything should render acceptably:

.form-check.form-check-inline .invalid-feedback {
  display: block;
}
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found