Validation at Angular 9

Asked

Viewed 29 times

0

I have a form, and in one of the inputs I need to do a validation so that when there are only blanks nothing happens. Example below:

 phone: [this.currentUser ? this.currentUser.user.phone : '', Validators.required],
 cpf: [this.currentUser ? this.currentUser.user.cpf : '', Validators.required],
 obs: [''] // Esse é o input a ser validado

Can someone give me a suggestion on how to do this?

1 answer

-1

Create a method and call it in front-end (input) = "removeSpace()"

 removeEspaco(){
    this.contact.patchValue({
      obs: this.contact.value.obs.replace(/^\s+/g, "")
    })
  }

Solved the problem.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.