My current reactive form setup is as follows:
this.loginForm = this._fb.group({
email: ['', [Validators.required, Validators.pattern('^[A-Za-z0-9._%+-]<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="99b2d9fef4f8f0f5b7faf6f4">[email protected]</a>$')]],
password: ['', Validators.required]
});
Regarding the HTML structure:
<!------------------------- PASSWORD FIELD ------------------------->
<div class="uk-margin">
<input type="password" class="uk-input"
placeholder="Enter Password" formControlName="password">
<!----- VALIDATION WARNINGS ----->
<div *ngIf="loginForm.get('password').touched">
<div *ngIf="loginForm.get('password').hasError('required')">
<div class="uk-text-danger"> Password is required.</div>
</div>
</div>
</div>
In terms of CSS styling:
.ng-valid[required] {
border: 5px solid #42A948;
}
.ng-invalid[required] {
border: 5px solid red;
}
The ng-valid/invalid
CSS rules are not changing the input field border color as expected. I'm unsure what I might be doing incorrectly. Can anyone provide assistance?
Update: