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

Validate ComboBox via Javascript

4 Answers 111 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Craig Hinkel
Top achievements
Rank 1
Craig Hinkel asked on 19 Jan 2009, 07:18 PM
Hello,

I am trying to validate a valid item is typed into one of my combo's with load on demand enabled and I am having a hard time with the javascript. I want to re-use a function for multiple combobox's.
        function ValidateComboUser(source, args)    
        {            
            var combo = $find(source.ControlToValidate.ClientID);   
            args.IsValid = ValidateCombo(combo);  
        }            
         
        function ValidateCombo(combo)  
        {  
           var isValid = false;    
           var text = combo.get_text();    
           var item = combo.findItemByText(text);    
             
           if (item)    
           {    
               isValid = true;    
           }   
             
           return isValid;  
        }  

Can someone please help me with a way to get the combo box being validated through the function params?

Thanks

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 20 Jan 2009, 07:32 AM
Hello Craig,

Try the following client-side function to validate the RadComboBoxItem.

JavaScript:
function ValidateComboUser(source, args)     
    var combo = $find(document.getElementById(source.id).getAttribute("controltovalidate"));  
    args.IsValid = ValidateCombo(combo); 
function ValidateCombo(combo) 
{   
   var isValid = false;     
   var text = combo.get_text();     
   var item = combo.findItemByText(text);  
   if (item)     
   {     
       isValid = true;     
   }      
   return isValid;   
}   

Thanks,
Shinu.
0
Craig Hinkel
Top achievements
Rank 1
answered on 20 Jan 2009, 05:18 PM
Thank you, that code worked perfectly.
0
Vijay
Top achievements
Rank 1
answered on 12 Aug 2015, 08:32 AM

I am getting this error while using the above code 

Uncaught Sys.ArgumentNullException: Sys.ArgumentNullException: Value cannot be null

0
Eyup
Telerik team
answered on 17 Aug 2015, 07:21 AM
Hello Vijay,

Do you have RadGrid on the page? If this is the case, the error may arise due to the following issue:
http://www.telerik.com/forums/value-cannot-be-null-parameter-name-key-exception-is-thrown-after-q2-2015-release

It is already fixed and you can download the latest release version to test that.

Regards,
Eyup
Telerik
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 Feedback Portal and vote to affect the priority of the items
Tags
ComboBox
Asked by
Craig Hinkel
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Craig Hinkel
Top achievements
Rank 1
Vijay
Top achievements
Rank 1
Eyup
Telerik team
Share this question
or