I have been looking into Bootstrap 4 - beta, however when using .is-invalid
with .input-group
it doesn\'t seem to show up.
You can always override styles using !important
Add this to your custom css file
.invalid-feedback{
display: inline !important;
}
To make it looks exactly the same you can use an inline if, in Laravel for example:
<input name="label" class="{{$errors->has('label') ? 'is-invalid' : '' }}">
@if ($errors->has('label'))
<div class="text-danger" role="alert">
<small>{{ $errors->first('code') }}</small>
</div>
@endif
The way Bootstrap does override the display
from none
to block
is by checking first for a previous is-invalid
class, for example! Check this CSS out:
That means, in case of an error, first is-invalid
must be applied on an element and then invalid-feedback
on another afterward! Like the following in Laravel, for instance:
{{-- Either following an input --}}
<input type="password" id="registerPassword"
class="form-control @error('register_password') is-invalid @enderror"
name="register_password" required autocomplete="new-password"
>
@error('register_password')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
{{-- Or separately in DOM --}}
@error('register_password')
<div class="is-invalid">...</div>
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
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>
I found this solution
<div class="input-group ">
<div class="input-group-prepend">
<div class="input-group-text">Start Date</div>
</div>
<input type="text" class="form-control is-invalid" placeholder="Date Input">
<div class="invalid-feedback order-last ">
Error Message
</div>
<div class="input-group-append">
<div class="input-group-text"><i class="fa fa-calendar"></i></div>
</div>
</div>
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. :)