Closed natcohen closed 8 years ago
IMO there is a limited set of validation rules when it comes typeaheads - required
is probably the most common one (I'm saying this since the whole idea of a typeahead is to present users with a set of valid matches - there is no point of presenting for selection an option that is invalid).
As of today a field that has a typeahead on it is editable by default (by "editable" I mean that whatever a user types in the input field gets propagated to the model). So in this sense as soon as a user starts typing something the field is "valid" (when it comes to the required
validator rule).
What you are really looking for is the equivalent of the typeahead-editable
option from http://angular-ui.github.io/bootstrap/#/typeahead. by switching on this option you could enforce a rule bu which users can only select an entry from the autcomplete. No selection = no model update => field not valid (from the "required") point of view.
@natcohen does the above make sense? Of so I'm going to rename this issue. BTW, we are planning to add editable
option anyway.
@pkozlowski-opensource Yes, this is exactly what I meant (typeahead-editable = false
)
this is exactly what I meant (typeahead-editable = false)
@natcohen well, the good news is that it just landed in master :-) Cutting a release today.
It is impossible to detect when a typeahead is valid (meaning that an item as been selected or match one of the list - and not just a random input). The input becomes valid whenever something is inserted. I'm using a model driven approach to forms.
Angular: 2.0.0
ng-bootstrap: 1.0.0-alpha.5
Bootstrap: 4-alpha 4