Reputation: 133
I am trying to make reactive form custom validation, From multiple set of inputs [text-boxes, radio button, select], Form get validated with true when any two input fields are filled or entered.
Upvotes: 1
Views: 211
Reputation: 410
For custom validation in form , you can set flag by check form control value in if condition and display message in HTML with that flag.
Example:
In the TS file:
flag:boolean;
if(this.demoForm.value.phone && this.demoForm.value.pin){
this.flag=false;
}else{
this.flag=true
}
In HTML file:
<span *ngIf='flag'>Your form is invalid</span>
Upvotes: 1