I was wondering if bootstrap 5 removed the validation state classes (.has-success
, .has-warning
, etc) since it suddenly didn't work and I can't seem to find those classes on the bootstrap.css
file.
Several months ago I could still use it and made a simple code like below:
<div class="form-group row mb-3" [ngClass]="{ 'has-error': !addOperator.controls['code'].valid && addOperator.controls['code']?.touched }">
<label for="code" class="col-sm-3 important col-form-label">
Company Code
</label>
<div class="col-sm-9">
<input formControlName="code" type="text" class="form-control" placeholder="Company Code" required="" maxlength="120" aria-required="true">
<span *ngIf="!addOperator.controls['code'].valid && addOperator.controls['code']?.touched"
class="help-block col-sm-offset-4">
Field is required
</span>
</div>
</div>
To this:
<div class="form-group row mb-3" >
<label for="code" class="col-sm-3 important col-form-label"
[ngClass]="{'text-danger': !addOperator.controls['code'].valid &&
addOperator.controls['code']?.touched }">
Company Code
</label>
<div class="col-sm-9">
<input formControlName="name" type="text"
[ngClass]="{ 'is-invalid': !addOperator.controls['code'].valid &&
addOperator.controls['code']?.touched }" class="form-control"
placeholder="Company Code" required="" maxlength="120" aria-required="true">
<span *ngIf="!addOperator.controls['code'].valid && addOperator.controls['code']?.touched"
class="help-block col-sm-offset-4" [ngClass]="{ 'text-danger': !addOperator.controls['code'].valid && addOperator.controls['code']?.touched }">
Field is required
</span>
</div>
</div>
Where it's not very practical when I have to change a large number of forms and inputs.
Thanks in advance, and sorry for the terrible format it's my first time asking here.