好吧,伙计们,
我已经阅读了有关 jQuery 验证插件的所有其他帖子和问题,他们似乎没有我想要做的事情。
我希望显示错误不与消息一起显示,而只是在输入字段周围创建一个红色边框。
这里只是一些表格:
<form id="donate_form" name="checkoutForm" method="post">
<label class="desc" id="title0" for="billing_name_first">
Name
<span id="req_1" class="req">*</span>
</label>
<div>
<span class="left">
<input name="billing.name.first" id="billing_name_first" type="text" class="field text required" value="" tabindex="1" />
<label for="billing_name_first">First</label>
</span>
<span class="right">
<input name="billing.name.last" id="billing_name_last" type="text" class="field text required" value="" tabindex="2" />
<label for="billing_name_last">Last</label>
</span>
</div>
我假设我需要将所需的类放在输入上?
然后用CSS隐藏label.error
哪个是插件吐出的?我已经尝试过了,但不行。
我找对地方了吗?
Thanks!
所有这些解决方案似乎都比实际需要的更复杂。这是一个简单的解决方案。.error
默认情况下会添加到无效字段。因此,我们需要做的第一件事是设计它的样式,以便将边框和背景更改为不同深浅的红色:
.error {
border-color: #cd0a0a !important;
background: #fef1ec !important;
}
然后,在 JavaScript 中:
$(function() {
$("#donate_form").validate({
errorPlacement: $.noop
});
});
The errorPlacement
选项是验证插件如何让您覆盖错误消息的放置方式。在这种情况下,我们只是让它不执行任何操作,因此不会创建错误消息。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)