I am finding some problem to correctly set CSS code related to validation status of a PrimeNG Text Area into an Angular project (this PrimeNG component: https://www.primefaces.org/primeng/showcase/#/inputtextarea )
Into a form I have declared a text area like this:
<div class="row">
<div class="col-2">
<p>Caratteristiche</p>
</div>
<div class="col-10">
<textarea id="assetFeatures" formControlName="asset_features" [rows]="5" [cols]="30" pInputTextarea autoResize="autoResize"></textarea>
</div>
</div>
That have the following validation rule defined into the TypeScript code of this component:
asset_features: [null, [Validators.required]],
So the browser render something like this (this is what I am obtaining looking the rendered code with Google Dev Tools):
<div _ngcontent-iaq-c66="" class="row">
<div _ngcontent-iaq-c66="" class="col-2">
<p _ngcontent-iaq-c66="">Caratteristiche</p>
</div>
<div _ngcontent-iaq-c66="" class="col-10">
<textarea _ngcontent-iaq-c66="" id="assetFeatures" formcontrolname="asset_features" pinputtextarea="" autoresize="autoResize" ng-reflect-name="asset_features" rows="5" cols="30" class="ng-untouched ng-pristine ng-invalid"></textarea>
</div>
</div>
So into my styles.css code of my project (where I put the validation CSS settings for others form fields, these others works fine) I put this code in order to highlight in red if the field is not valid:
.p-inputtextarea.ng-untouched.ng-invalid .ui-inputtext,
.p-inputtextarea.ng-dirty.ng-invalid .ui-inputtext ,
.p-inputtextarea.ng-touched.ng-invalid .ui-inputtext {
border: 1px solid red !important;
background: rgba(255, 0, 0, 0.35);
box-shadow: 0 0 5px 1px rgba(255, 0, 0, 0.2) inset !important;
}
I also tried in this way:
p-inputtextarea.ng-untouched.ng-invalid .ui-inputtext,
p-inputtextarea.ng-dirty.ng-invalid .ui-inputtext ,
p-inputtextarea.ng-touched.ng-invalid .ui-inputtext {
border: 1px solid red !important;
background: rgba(255, 0, 0, 0.35);
box-shadow: 0 0 5px 1px rgba(255, 0, 0, 0.2) inset !important;
}
In both cases the CSS settings are not applied, this is what I am obtaining:
As you can see the style for invalid textarea is not applied.
Why? What is wrong? What am I missing? How can I try to fix it?