ComboBox ClientSide Validation

4 posts, 0 answers
  1. DK
    DK avatar
    72 posts
    Member since:
    Jun 2009

    Posted 10 Aug 2009 Link to this post

    I have radcombobox.
    now when my page loads some values are selected in the combobox.
    now i m checking client side that if  something is selected in the combobox then i disable a radtextbox and if nothing is selected then i enable the same.

    now i have added a custom validator on another combobox which is dependent on the first combobox.
    if first combobox is not selected then no validation and if the first combobox have selected value and second combo have not any selected value then i show error.

    i used
    function validate(sender,args)
    cmb1=$find("<%= cmb1ID.ClientID%>");

    cmb2=$find("<%= cmb2ID.ClientID%>");

    if(cmb1.get_selectedIndex()>0 && cmb2.get_selectedIndex()<0) // I have also used cmb1.get_value() and cmb1.get_selectedItem()

    and the first item in my combobox is null and second item is "Please Select" and the remaining items are there.
    alnd aloow custom text is true.

    please help me to validate the above problem
    its urgent.

  2. Atanas Korchev
    Atanas Korchev avatar
    8462 posts

    Posted 12 Aug 2009 Link to this post

    Hello DK,

    We are not sure what the exact scenario is. Could you please open a support ticket and send us a sample page which shows the issues you are experiencing? Thanks.

    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. DevCraft R3 2016 release webinar banner
  4. Tim
    Tim avatar
    3 posts
    Member since:
    Mar 2009

    Posted 20 May 2010 Link to this post

    Was a solution found to this because I have the same problem, the first item is returned as null and subsequent records are numbered from index 0.  The problem is the selecteditem even later if the first one is picked is null and therefore useless.

    I want to use a common javascript code to validate from the custom validators and ensure the page is valid before submission

    Code Below
    <script type="text/javascript">  
            function ReqFieldValidationCBox(source, arguments) {              
                var Cbox = $find(source.controltovalidate);  
                if (Cbox) {  
                    if (Cbox.get_selectedIndex() == null || Cbox.get_selectedIndex() == "") {  
               = "solid 1px red";  
                        arguments.IsValid = false;  
                    else {  
               = "";  
                        arguments.IsValid = true;  
            function clientSelectedIndexChange(sender, args) {  
     <asp:CustomValidator ID="cvLicensest" runat="server" ControlToValidate="txtStockCode" ValidateEmptyText="true"  ClientValidationFunction="ReqFieldValidationCBox" CssClass="error" EnableClientScript="true" Display="Dynamic"  /> 
            ID="txtStockCode" runat="server" 
            Width="250px" Height="140px"   
            EmptyMessage="Enter or Pick Stock Code" 
            EnableLoadOnDemand="true" ShowMoreResultsBox="true"   
            Culture="English (United Kingdom)">  
        <WebServiceSettings Path="~/services/SuppliesSvc.svc"   
        Method="LoadStockData" /> 

    I'm sure this is not a bug but a feature I don't understand but need a way around it. 

    Once the validation is work for forcing a selection the next step is to make sure they haven't just got Custom text because it doesn't seem to restrict input the nodes loaded. 

    Thanks in advance.

  5. Kalina
    Kalina avatar
    918 posts

    Posted 25 May 2010 Link to this post

    Hi Tim,

    I made a small sample page using the code snippets that you sent to us and I can say that on my side your code works properly.

    When you use Load-On-Demand feature, the RadComboBox SelectedItem is not persisted server-side, however you can use SelectedValue and Text server-side properties. Please find more details at this help article.

    All the best,
    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.
Back to Top