Jquery validation and RadCombobox

10 posts, 0 answers
  1. pnr
    pnr avatar
    26 posts
    Member since:
    Jan 2007

    Posted 16 Mar 2010 Link to this post

    I am using Jquery validation (http://docs.jquery.com/Plugins/Validation) on my site, but i can't make it validate my RadCombobox's. Could you show me how that can be done?

    Thanks in advance!
  2. Kalina
    Admin
    Kalina avatar
    918 posts

    Posted 19 Mar 2010 Link to this post

    Hi pnr,

    To validate the input of the RadComboBox you can use the rules feature explained in the JQuery online documentation.

    <script type="text/javascript">
      
        $(document).ready(function() {
      
            $("#commentForm").validate();
      
            $(".rcbInput").rules("add", {
                required: true,
                minlength: 2,
                messages: {
                    required: "Please select"
                }
            });
      
            $(".rcbInput").validate();
      
        });
    </script>

    More details you can find at the sample project attached.

    Kind regards,
    Kalina
    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. pnr
    pnr avatar
    26 posts
    Member since:
    Jan 2007

    Posted 20 Mar 2010 Link to this post

    Hi Kalina

    Thank you very much for your answer! I have a little problem with your demo, when i add 2 RadComboBoxes it only validate the first that occur. Why is that?

    Thanks in advance!
     
  5. Kalina
    Admin
    Kalina avatar
    918 posts

    Posted 23 Mar 2010 Link to this post

    Hi pnr,

    In fact the JQuery class selector gets an array of elements with the specific class applied.
    So you can assign the validation rule array elements using each() function:
     
    <script type="text/javascript">
     
        $(document).ready(function() {
            $("#commentForm").validate();
            $(".rcbInput").each(function() {
                $(this).rules("add", {
                    required: true,
                    minlength: 2,
                    messages: {
                        required: "Please select"
                    }
                });
            });
            $(".rcbInput").validate();
     
        });
         
    </script>

    More details you can find at the sample page attached.

    Best wishes,
    Kalina
    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.
  6. pnr
    pnr avatar
    26 posts
    Member since:
    Jan 2007

    Posted 23 Mar 2010 Link to this post

    Thank you very much for the excellent help!
  7. Anup
    Anup avatar
    4 posts
    Member since:
    Feb 2011

    Posted 19 Apr 2011 Link to this post

    The solution provided does not seem to work when the radcombo is contained in an ascx file.
    In my case I also have twon instances of the same ascx on a page. Any help will be highly appriciated.

    Regards
  8. Kalina
    Admin
    Kalina avatar
    918 posts

    Posted 21 Apr 2011 Link to this post

    Hi,

    On my side the solution works properly when RadComboBox is nested within a user control.
    Please find more details at the sample attached.

    Greetings,
    Kalina
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  9. Anup
    Anup avatar
    4 posts
    Member since:
    Feb 2011

    Posted 21 Apr 2011 Link to this post

    Hi Kalina

    Thanks for this solution. well on our end we had master pages being used and the same ascx was nested twice into a page. We finally decided to not use the jquery validation and stuck to; out of the box Asp.net validators. It works fine now.

    thanks a lot for your effort. We really appriciate it.

    Regards
  10. Neehar
    Neehar avatar
    5 posts
    Member since:
    Dec 2012

    Posted 05 Dec 2012 Link to this post

    Hi,
    I have applied validation for RadCombo Box but the error message is displayed below the 
    combobox, but i need to display error message right side of radcombobox,
    please help me ,

    Thank You.
  11. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 06 May 2013 Link to this post

    Hi Neehar,

    Please check the following CSS.

    CSS:
    <style type="text/css">
        label.error
        {
            color: red;
            margin-left: 40px;
            position: fixed;
        }
    </style>

    Thanks,
    Princy.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017