Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/88.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
JQuery验证单选按钮组_Jquery_Html_Validation_Jquery Plugins_Jquery Validate - Fatal编程技术网

JQuery验证单选按钮组

JQuery验证单选按钮组,jquery,html,validation,jquery-plugins,jquery-validate,Jquery,Html,Validation,Jquery Plugins,Jquery Validate,我正在使用jquery的验证器插件来验证我的整个表单。我有一组单选按钮如下: <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="o

我正在使用jquery的验证器插件来验证我的整个表单。我有一组单选按钮如下:

<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>

但它会在选项1旁边显示所需消息,使其看起来像是需要单选按钮。相反,我想在需要至少选择一个单选按钮的所有单选按钮上方显示一条自定义消息。

啊,好的,现在我如何使显示成为自定义消息?@MichaelBenneton
,消息:{“选项”:“我的错误消息”}…
@HalilÖzgür,如果您希望错误标签正好出现在最后一个
选项3
和关闭
标记之间,您会怎么做?谢谢。@Ricardo,
element.parents(“div:first”).append(错误)
注意使用
append
而不是
before
$(".form").validate({
    ...
    ,errorPlacement: function (error, element) {
        if (element.is("input:radio")) {
            element.parents("div:first").before(error);
        } else {
            element.after(error);
        }
    }
    ...
});
$(".form").validate({
    ...
    ,errorPlacement: function (error, element) {
        if (element.is("input:radio")) {
            element.parents("div:first").before(error);
        } else {
            element.after(error);
        }
    }
    ...
});