I am new in angular. I have one scenario where I need only one field required from 5 fields in the form, means if the user fills at least one field then form makes valid.
Thanks in advance.
I am new in angular. I have one scenario where I need only one field required from 5 fields in the form, means if the user fills at least one field then form makes valid.
Thanks in advance.
Check this example of phone number validator
in form-validator file
let me know if you have any doubts.
Since you need to check for the validity of whole form only if one of the fields is non empty , You can manually set the validity like below :
Where
this.valid
is your condition based on which you can set the validityYou can check the example : https://angular-exmphk.stackblitz.io
You can also check the answer : FormGroup validation in "exclusive or" which does form validation based on some condition
Hope this helps