【发布时间】:2016-10-21 13:13:07
【问题描述】:
我想在错误摘要和复选框后的标签中为同一控件显示不同的错误消息。
如果复选框没有勾选,
总之,我想显示“您必须勾选版权确认复选框才能继续。”
在相邻的复选框标签中,我想显示“必须选中才能继续”
js:
$.validator.addMethod("chkCopyright", function (value, element) {
return $('#chkCopyright').is(':checked');
}, "You must tick the Copyright Confirmation checkbox to continue.");
html代码:
<label class="checkbox-inline">
<input type="checkbox" name="chkCopyright" data-rule-chkCopyright="true" value="1" data-msg-chkCopyright="must check to continue"> I confirm that there are no copyright restrictions on this repro request. <span class="text-danger field-validation-valid" data-valmsg-for="chkCopyright" data-valmsg-replace="true"> </span>
</label>
但当验证失败时,data-msg 中的消息会超车并显示在错误摘要中。
【问题讨论】:
标签: jquery jquery-validate unobtrusive-validation