Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap 4 invalid feedback with input group not displaying

I have been looking into Bootstrap 4 - beta, however when using .is-invalid with .input-group it doesn't seem to show up.

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" rel="stylesheet" />  <div class="form-group">    <label for="label">Label</label>    <div class="input-group">        <div class="input-group-addon">        label      </div>      <input type="text" value="" name="label" class="form-control is-invalid">    </div>      <div class="invalid-feedback is-invalid">      <strong>Invalid Label</strong>    </div>  </div>

How are you meant to display an invalid message while using .input-group?

Adding the following CSS works as a workaround, but it seems odd.

.form-group.is-invalid {     .invalid-feedback {         display: block;     } } 
like image 244
Ian Avatar asked Aug 14 '17 11:08

Ian


People also ask

How can we make input field mandatory in bootstrap?

1. Required attribute: If you want to make an input mandatory to be entered by the user, you can use the required attribute. This attribute can be used with any input type such as email, URL, text, file, password, checkbox, radio, etc. This can help to make any input field mandatory.

Which class does bootstrap 4 provide in order to be used only when the form control is invalid?

Here's how form validation works with Bootstrap: HTML form validation is applied via CSS's two pseudo-classes, :invalid and :valid . It applies to <input> , <select> , and <textarea> elements. Bootstrap scopes the :invalid and :valid styles to parent .was-validated class, usually applied to the <form> .

How do I show a field required in bootstrap?

This is pretty useful in giving a visual indication to the user when a form field is required. There will now be a nice little “*” after the label for “Required Field”.

What is bootstrap input group?

Bootstrap 4 Input Groups input-group class is a container to enhance an input by adding an icon, text or a button in front or behind the input field as a "help text". Use . input-group-prepend to add the help text in front of the input, and . input-group-append to add it behind the input.


2 Answers

Boostrap 4 is very buggy. My suggestion is to replace:

 <div class="invalid-feedback">  Text here  </div> 

With:

<div class="text-danger"> Text here </div> 

And the second one looks virtually the same and will not fail.

For a better look, try:

<div class="text-danger"> <small>Text here</small> </div> 
like image 176
JG Estiot Avatar answered Sep 28 '22 02:09

JG Estiot


They haven't taken into account their own examples using input group addons and buttons, even with a column model. The markup does only facilitate "neighboring" elements, not parent > neighboring element (there is no CSS rule for that).

It seems, for now, you should fall back to Alpha 6 or program your own CSS classes accordingly. I've done the same, unfortunately.

Please note when reading my answer that this was posted just as the beta was released. :)

like image 23
ReSpawN Avatar answered Sep 28 '22 03:09

ReSpawN