jQuery Validate 将错误视为单独的实例,而不是组合它们
我能够将 jquery 验证错误重新定位到表单上方的特定容器集,但元素显示为单独的错误(多个)。
理想情况下,我想要一个大的错误框(在我的其他页面上我已经使用类“错误”来调用它)并声明一长行“请修复以下错误:...” 结果是一个无序列表。
我的 jquery 如下:
<script type="text/javascript">
$(function() {
$("#login_form").validate({
errorLabelContainer: "#containererreurtotal",
wrapper: "li",
errorClass: "error",
rules: {
AGTNO: 'required',
AGTPW: 'required'
},
messages: {
AGTNO: 'Your Number or Email Address is required.',
AGTPW: 'Your Password is required.'
},
submitHandler: function(form) {
$('body').append('<div id="overlay"></div>');
$('#overlay').show();
form.submit();
}
});
});
</script>
在我的表单上方,我有以下内容:
<ul id="containererreurtotal"></ul>
我有什么想法出错了吗?
I am able to relocate my jquery validate errors to specific container set above my form but the elements show up as separate errors (multiple).
Ideally, I want to have one large error box (which on my other pages I already call with class 'error') and state something a long the lines of "Please fix the following errors:..."
with the results being an unordered list.
My jquery is as follows:
<script type="text/javascript">
$(function() {
$("#login_form").validate({
errorLabelContainer: "#containererreurtotal",
wrapper: "li",
errorClass: "error",
rules: {
AGTNO: 'required',
AGTPW: 'required'
},
messages: {
AGTNO: 'Your Number or Email Address is required.',
AGTPW: 'Your Password is required.'
},
submitHandler: function(form) {
$('body').append('<div id="overlay"></div>');
$('#overlay').show();
form.submit();
}
});
});
</script>
Above my form, I have the following:
<ul id="containererreurtotal"></ul>
any ideas where I am going wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
http://jsfiddle.net/HK4TP/1/
隐藏错误容器并为其指定适当的样式,其余的将由插件处理。
http://jsfiddle.net/HK4TP/1/
Hide your error container and give it the appropriate styling, the rest will be handled by the plugin.