ComboBox jQuery Validation not working with "Empty Message" attribute set

2 posts, 0 answers
  1. Mohamed
    Mohamed avatar
    7 posts
    Member since:
    Oct 2012

    Posted 04 May 2013 Link to this post

    I have a similar issue to the one mentioned at:
    http://www.telerik.com/community/forums/aspnet-ajax/combobox/jquery-validation-and-radcombobox.aspx

    The solution provided is working well unless I set a value for the ComboBox "Empty Message" attribute, i.e, the message that appears within the ComboBox to tell the user to select a value.

    Any solution?
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 06 May 2013 Link to this post

    Hi Mohamed,

    Please have a look at the following code I tried without giving any Default Item which works fine at my end.

    ASPX:
    <form runat="server" id="myForm1" method="get" action="">
    <asp:ScriptManager ID="ScriptManager1" runat="server" />
    <div>
        <label for="text1">
            Enter Text</label>
        <input type="text" id="text1" class="required" />
        <br />
        <br />
        <label for="RadComboBox1">
            RadComboBox</label>
        <telerik:RadComboBox ID="RadComboBox1" runat="server" EnableLoadOnDemand="true" OnItemsRequested="RadComboBox1_ItemsRequested">
        </telerik:RadComboBox>
        <br />
        <br />
        <input id="Submit1" class="submit" type="submit" value="Submit" runat="server" />
    </div>
    </form>

    JavaScript:
    <script type="text/javascript" src="../jquery/jquery-1.4.2.js"></script>
    <script type="text/javascript" src="../jquery-validate/jquery.validate.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
     
            $("#myForm1").validate();
     
            $(".rcbInput").rules("add", {
                required: true,
                minlength: 2,
                messages: {
                    required: "Select an Item"
                }
            });
     
            $(".rcbInput").validate();
     
        });
    </script>

    CSS:
    <style type="text/css">
        label.error
        {
            color: red;
        }
    </style>

    Thanks,
    Princy.
Back to Top