Enable "search" button only after user type 5 letters - IONIC V3

Asked

Viewed 55 times

-1

I have a select that returns 73,000 records, so I’m filtering it, but I need this filter to have at least five letters when searching. Translating: I need that in real time the "search" button is only available when at least 5 letters are typed, it is possible ?

1 answer

0


Yes, it is possible.

Consider that you have an input as below:

<ion-item>
  <ion-label floating>Buscar</ion-label>
  <ion-input [(ngModel)]="buscar" (ionChange)="enableButton()" type="text"></ion-input>
</ion-item>

<button ion-button color="primary" disable="disableButton" (click)="buscar()">Buscar</button>

So we might have something like this to control the state of the search button.

enableButton() {
  this.disableButton = this.buscar && this.buscar.length < 5;
}

  • I made some adaptations, but it worked!! Thanks man!

  • I’m glad it worked out! If possible, please evaluate my reply. Thank you!

Browser other questions tagged

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