将验证消息移动到新位置

Move validation message to a new place

本文关键字:位置 新位置 验证 消息 移动      更新时间:2023-09-26
<p class="section requiredtext">some text<br />
<textarea class="title required" id="foo" name="foo"></textarea>
</p>

如何让 jquery 验证在与"某些文本"标题相同的行上显示"必填字段"错误消息。我尝试了一些方法,但我做不好。多谢。

$('form').validate({
    errorPlacement: function(error, element) {
        error.prependTo(element.parent());
    }
});