This is a migrated thread and some comments may be shown as answers.

How do I force a valid selection?

3 Answers 197 Views
AutoComplete
This is a migrated thread and some comments may be shown as answers.
PaulMrozowski
Top achievements
Rank 1
PaulMrozowski asked on 17 Jul 2012, 10:46 PM
I only want users to be able to leave my autocomplete field empty, or select an item from the list - I don't want them able to enter their own "new" item. How can I force a valid selection (either by clearing the invalid data, or not allowing the focus to leave the control, or some other variation)?

3 Answers, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 18 Jul 2012, 10:49 AM
Hello Paul,

The easiest and most logical approach is to use a DropDownList. Users will not be able to type, but once the dropdown is open and a key is pressed, the first item starting with the pressed key will be focused for faster access.

Clearing a typed value, forcing a focused state or similar practices are not considered user-friendly.

All the best,
Dimo
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
PaulMrozowski
Top achievements
Rank 1
answered on 18 Jul 2012, 02:11 PM
 Unfortunately the dropdownlist isn't really workable. In this case the user is selecting from what could be thousands of items and it needs to have the ability to search across a few fields in a table. 

I noticed that the select event fires when the user selects a valid entry. Is there any other event available when they clear the entry, or when they have entered something that isn't valid (basically any event that would fire whenever the select doesn't, but something has changed)? I guess worse case I could hook into the onfocus/onblur of the underlying textbox and try to track this myself.
0
Dimo
Telerik team
answered on 18 Jul 2012, 02:40 PM
Hello Paul,

You must have noticed that there is also a change event. In my opinion, it is more convenient than select.

Regards,
Dimo
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
AutoComplete
Asked by
PaulMrozowski
Top achievements
Rank 1
Answers by
Dimo
Telerik team
PaulMrozowski
Top achievements
Rank 1
Share this question
or