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

[Solved] combo box client side validation

3 Answers 165 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
bob ter
Top achievements
Rank 1
bob ter asked on 29 Jan 2010, 04:05 PM
Hi,

I have a populated combo box with 'allow custom text' and 'mark first match enabled' in order for users to be able to type in the box and have any matches autopopulate.

However I would like to validate on the client side for when they type something into the box which isn't in the populated list. Ive tried using a required field validator but as theres something in the box they dont catch that whats in the box isn't in the list.

Any ideas?

3 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 01 Feb 2010, 08:15 AM
Hello,

Attach 'OnClientBlur' event to RadComboBox for checking whether the typed value is present in RadComboxItem collection, if not set the combo text as blank.

Client Code:
 
    function OnClientBlur(sender, args) { 
        var check = false
        for (var i = 0; i < sender.get_items().get_count(); i++) { 
            if (sender.get_text() == sender.get_items()._array[i].get_text()) { 
                check = true
            } 
        } 
        if (!check) 
            sender.set_text(''); 
    }     

Hope this help you,
Shinu.
0
Simon
Telerik team
answered on 01 Feb 2010, 10:54 AM
Hi bob ter,

You could also try the second approach in this help article.

Greetings,
Simon
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
bob ter
Top achievements
Rank 1
answered on 01 Feb 2010, 01:45 PM
thanks guys they both worked great
Tags
ComboBox
Asked by
bob ter
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Simon
Telerik team
bob ter
Top achievements
Rank 1
Share this question
or