I'm using jquery's validator plugin to validate my entire form. And I have a set of radio buttons like this:
<div class="radio_options" style="display:none; margin-left:7px;">
<label><input type="radio" name="options" value="1"> Option1</label>
<label><input type="radio" name="options" value="2"> Option2</label>
<label><input type="radio" name="options" value="3"> Option3</label>
</div>
I know I can just put
class="required"
But it displays the required message next to option 1 making it look like that radio button is required. Rather I want to display a custom message above all the radio buttons requiring at least one be selected.
$(".form").validate({
...
,errorPlacement: function (error, element) {
if (element.is("input:radio")) {
element.parents("div:first").before(error);
} else {
element.after(error);
}
}
...
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With