Validate ComboBox via Javascript

5 posts, 0 answers
  1. Craig Hinkel
    Craig Hinkel avatar
    36 posts
    Member since:
    May 2008

    Posted 19 Jan 2009 Link to this post

    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
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 20 Jan 2009 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Craig Hinkel
    Craig Hinkel avatar
    36 posts
    Member since:
    May 2008

    Posted 20 Jan 2009 Link to this post

    Thank you, that code worked perfectly.
  5. Vijay
    Vijay avatar
    1 posts
    Member since:
    Feb 2015

    Posted 12 Aug 2015 in reply to Shinu Link to this post

    I am getting this error while using the above code 

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

  6. Eyup
    Admin
    Eyup avatar
    3012 posts

    Posted 17 Aug 2015 Link to this post

    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
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017