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

ComboBox - Validation

7 Answers 236 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jigar
Top achievements
Rank 1
Jigar asked on 04 Sep 2010, 10:12 PM
Hi Guys,

While using combo box, auto complete, user may enter such value which is not suggested or not in a list. How can we make sure that the user has selected value within the given list.

I understand that I can use drop down list in above scenario. But Want to know the work around for auto complete or combo box.

I was looking at the Server Validation of the combo box Demo, In this demo it gives error "Error! Requested URL didn't return json".

Thanks In Advance,
Jigar.

7 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 06 Sep 2010, 08:11 AM
Hi Jigar,

 Actually this is the intended behavior of the autocomplete and combobox - to allow custom values to be entered. I also checked the server validation demo - but it didn't display such problems. 

Perhaps the right way to do this is to perform the check on the server side. The autocomplete and combobox by design allow custom text to be entered so there is no need to prevent that.

Greetings,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Jigar
Top achievements
Rank 1
answered on 06 Sep 2010, 08:52 AM
Hi Atanas,

thanks a lot for your input on this. I really appreciate it.

I will try to validate the input on server side.

On server validation demo; If you put enter "xxxxxxx" in Product Name and click on Save, it will return the the error saying "Error! Requested URL didn't return json".

Thanks,

Jigar
0
Jigar
Top achievements
Rank 1
answered on 06 Sep 2010, 08:57 AM
Opps Sorry,

My Mistake. I dont see such error now.

Regards,

Jigar
0
Casey
Top achievements
Rank 1
answered on 04 May 2011, 10:29 PM
Just saw this question and it's a number of months since but for those looking for a different solution...

I'm using the ComboBox as a kind of "AutoCompleteWithDropDown" so that the users can search long lists, but I ultimately want them to pick a valid entry.  

Rather than extend AutoComplete, I set up a client-side OnChange event that checks the selectedIndex property.  If it's < 0, it means that nothing from the list has been selected.  Based on that, I disable some other controls on the page.  

Probably not exactly what you had in mind in terms of validation, but you might be able to use a similar approach (i.e., before the form posts, do that check and prevent the post from happening and notify the user as you see fit)

@(Html.Telerik().ComboBox()
                .Name("ClientCombo")
                .DataBinding(binding => binding.Ajax().Select("ListClients", "TSM"))
                .DropDownHtmlAttributes(new { style = string.Format("width:{0}px", 550) })
                .ClientEvents(events => events.OnChange("onClientComboChanged"))
                .Filterable(filtering => { filtering.FilterMode(AutoCompleteFilterMode.Contains); }).HighlightFirstMatch(true))


function onClientComboChanged(e) {
    var combo = $(this).data('tComboBox');
    disableInsert(combo.selectedIndex < 0);
}
0
Robert
Top achievements
Rank 1
answered on 09 Dec 2011, 12:05 AM
Maybe this has changed in the most recent release, but I have the same issue as the original poster.

Having an autocomplete lookup using the ComboBox with long lists (like a list of US States) while preventing custom values from being entered may not be supported currently, but I am puzzled as to the answer from Telerik here, that "The autocomplete and combobox by design allow custom text to be entered so there is no need to prevent that."

Looking at the RadComboBox AJAX control, preventing custom text isn't anything new with a Telerik ComboBox (http://www.telerik.com/help/aspnet-ajax/combobox-select-existing-item.html).
0
Georgi Krustev
Telerik team
answered on 09 Dec 2011, 03:21 PM
Hello Robert,

 
We are aware that the RadComboBox supports preventing custom text. Unfortunately, this functionality cannot behaves equally in all possible scenarios. For instance, combobox with load on demand could allow custom text if the items are not loaded yet. That is why, we suggest use DropDownList in this case. You can find more information about the components here.

Best regards,
Georgi Krustev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
0
Anthony Terra
Top achievements
Rank 1
answered on 22 Feb 2012, 05:43 PM
This may be late, but I am using a Regular Expression Validator to ensure the value of the item is correct, if the user enters an item not in the list of values it fires.  My situation I have a very specific rules around how the value will be formatted so it works well in my situation.
Tags
ComboBox
Asked by
Jigar
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Jigar
Top achievements
Rank 1
Casey
Top achievements
Rank 1
Robert
Top achievements
Rank 1
Georgi Krustev
Telerik team
Anthony Terra
Top achievements
Rank 1
Share this question
or