0

I create a search bar. When the user presses the letter 'A' I want to display the users whose first name starts with the letter 'A'. It works.

I want to disregard uppercase or lowercase and accented letters. In other words, I want that if the user types an 'A' or 'a', my program displays all users starting with 'A'. And if he types a 'e' instead a 'é', it works too.

Here is my program to obtain the value entered by the user :

searchUser(): void {
  let str;
  let element = document.getElementById('chat-window-input');

  if(element !== null) {
    str = (element as HTMLInputElement).value;
  }
  else {
    str = null;
  }
  if(!str) {
    this.searchArrayThreads = [];
  }
}

Here is my condition for test the value entered by the user :

if(thread.participants[0].name.startsWith(str)) {
      return thread;
}

So I think I need to create an other variable like str and modify this variable..

Is it possible to do this simply?

Nolyurn
  • 568
  • 4
  • 17
Floriane
  • 315
  • 6
  • 20

0 Answers0