Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.

Join them; it only takes a minute:

Sign up
Join the Stack Overflow community to:
  1. Ask programming questions
  2. Answer and help your peers
  3. Get recognized for your expertise

I'm using the getbootstrap typeahead to populate an input value. I've setup everything so that the user has to pick something from this list:

<input type="text" class="form-control" id="birdname" ng-model="birdname" required ng-disabled="checked" autocomplete="off" placeholder="Check the box if you don't know!" 
                uib-typeahead="bird for bird in birds | filter:$viewValue | limitTo:8" typeahead-no-results="noResults"
                uib-tooltip="Pick a bird or check the box if unsure!"
                tooltip-placement="top-right"
                tooltip-trigger="mouseenter"
                tooltip-enable="!birdname">
        </div>
        <div ng-show="noResults">
          <i class="glyphicon glyphicon-remove"></i> No Results Found - Please Try Again!
        </div>

As you can see, the user has to pick something from this list or the validation won't allow it, though I am having one issue: If the user starts typing and is typing a birdname that exists (list showing with birds on input), but then clicks out of the input with his mouse. typeahead accepts this as 'correct' even though the full name hasn't been picked.

Is there a fix to this?

If you didn't understand what I mean, the following picture should hopefully explain it:

Error

Is there a solution to this? For example, it picking the first option in the list when clicked?

share|improve this question
    
Typeahead is for another tasks.. For your needs use angular-ui.github.io/ui-select – Max 16 hours ago
1  
There is a typeahead-select-on-blur option for the uib-typeahead directive which on blur will select the currently highlighted match (documentation). – Pieter 16 hours ago
    
@Max How is typeahead not mean for this? – Cedric Bongaerts 16 hours ago
    
@Pieter Thanks peter, that did the trick! Exactly what I needed. When clicked out of the field, it selects the first one. – Cedric Bongaerts 16 hours ago

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.