chintu
chintu

Reputation: 17

Auto-Complete TextInput - Match Beginning of String Only

My question concerns the following tutorial I've been working through:

Building a Flex Type-Ahead Text Input

I was successful in enabling a search of available terms using the characters entered in the input, but only irrespective of the location of the characters in the terms. However, I am wondering how one might have the characters match only the beginning of the terms.

For example, suppose I enter the string "app" into the text input. How can I get only "apple" and not, for instance, "pineapple" to appear as an option?

Upvotes: 0

Views: 1340

Answers (1)

www0z0k
www0z0k

Reputation: 4434

public function filterSelection(item:Object):Boolean{
 if (String(item).indexOf(fruit.text)==0){
    return true;
  }
    return false;
}

Upvotes: 2

Related Questions