user2255811
user2255811

Reputation: 496

validate multiple radio button groups using jquery validator

I have 6 sets of radio buttons, all independent of each other. Im using JQuery validation plugin to validate them(they are all required). However the validation only works on the first one the 'satisfaction' group. My validation code is here

jQuery(document).ready(function() {
$("#surveyForm").validate({
    rules: {
        satisfaction: {
            required: true
        },

        responding: {
            required: true
        },

        listening: {
            required: true
        },

        solution: {
            required: true
        },

        communication: {
            required: true
        },

        professional: {
            required: true
        }

    },
    messages:{
        satisfaction: {
            required: "this"
        },

        responding: {
            required: "is"
        },

        listening: {
            required: "a"
        },

        solution: {
            required: "test"
        },

        communication: {
            required: "to"
        },

        professional: {
            required: "see"
        }
    }
});

});

Any suggestions?

JS Fiddle

Upvotes: 0

Views: 3782

Answers (1)

Barmar
Barmar

Reputation: 780673

You had <div id="q1"> before <form id="surveyForm">, so the matching </div> was terminating the form.

Change the order of those two lines and the problem is resolved.

FIDDLE

Upvotes: 1

Related Questions