How can I validate the input type="radio"

5 posts, 0 answers
  1. Wichit
    Wichit avatar
    1 posts
    Member since:
    Apr 2012

    Posted 08 May 2012 Link to this post

    I'm newbie ,Help me please. How can I validate the input type="radio"? 
    My code is : 
    <input id="connectionType" name="connection" type="radio" value="1" required validationMessage='<spring:message code="ui.customer.create.require.connection"/>' />
    <spring:message code=""/>

    <input id="connectionType" name="connection" type="radio" value="2" required validationMessage='<spring:message code="ui.customer.create.require.connection"/>'/>
    <spring:message code="ui.customer.create.lable.connection.exist"/>

    and javascript is : 
        var validatable = $("#create_window").kendoValidator().data("kendoValidator");
        if (validatable.validate()) {
        return false;
  2. Rosen
    Rosen avatar
    3253 posts

    Posted 10 May 2012 Link to this post

    Hi Wichit,

    You should register a custom validation rule to validate the radio buttons as shown in the following jsFiddle:

    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Aaron
    Aaron avatar
    2 posts
    Member since:
    Sep 2011

    Posted 19 Oct 2012 Link to this post

    I ran into this as well. The snippet provided is almost right, but it goofs up other validations you might have setup.

    What appears to work for me is:

    rules: {
               radio: function(input) {
                   if ("[type=radio]") && input.attr("required")) {        
                      return $("#newStatusOverride").find("[name=" + input.attr("name") + "]").is(":checked");
                   return true;
               messages: {
                   radio: "Please select a status"

    The difference being changing the .filter to .is

  4. yamaha
    yamaha avatar
    7 posts
    Member since:
    Sep 2015

    Posted 16 Oct 2015 in reply to Aaron Link to this post

    I know this is an old post but thought it was worth try asking. My requirement is there are set of 2 radio buttons and only one of them can be selected. I have given them same 'name' and that functionality works. I have a custom rule defined which checks to see if "Physician" radio button is checked then we validate that a "Speciality" from the specialty dropdown has been selected.

    The problem I am running into is that when I check Physician radio button and do not select a Specialty I get an error pop-up which is blank. No error message. I have around 15 other custom validation on same page which form flawlessly. 

    Here is link to my code.

     Do you see anything wrong with the way I have written my html or custom validator rule ?


  5. Daniel
    Daniel avatar
    2231 posts

    Posted 21 Oct 2015 Link to this post


    The code looks correct. I updated the example to bind a sample ViewModel to the form and the message is shown correctly. Please check the example and let me know if I am missing something. 

    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top