Hello,

I am trying to validate a form with radio inputs. I want to the form
to be submitted only if an option was selected:

 <form action="/Poll/Vote/1" class="Poll" id="Poll" method="post">
    <fieldset>
      <label for="OptionsArray">Do you like to travel?</label>
      <input type="radio" name="OptionsArray" id="1" value="1"
class="Radio" />
      <label for="1">Yes</label>
      <input type="radio" name="OptionsArray" id="2" value="2"
class="Radio" />
      <label for="2">No</label>
      <input id="Submit" name="Submit" type="submit" value="Vote" /
>
    </fieldset>
  </form>

I used:

      $("#Poll").each(function() {
        $(this).validate({
          errorClass: "Error",
          errorElement: "label",
          rules: {
            OptionsArray: { required: true }
          },
          messages: {
            OptionsArray: { required: "You didn't choose your vote" }
          }
        });
      });

The form is submitted even if I don't choose an option!

If I select an option I get an error on Firebug:
 validator.settings["on" + even... + event.type].call(validator,
this[0]);

Could someone tell me what am I doing wrong?

Thank you,
Miguel

Reply via email to