表格的错误放置 [英] Error Placement of a Form

查看:59
本文介绍了表格的错误放置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过第二种形式使用以下插件,该插件将所有错误消息放置在其单独的div中.唯一的不同是,它们将其放置在其上方,而我将思想放置在其下方.但是它仍然没有为我显示div内的消息.不知道为什么.

http://jquery.bassistance.de/validate/demo/errorcontainer- demo.html

演示: http://jsfiddle.net/xtremer360/KHSKm/1/

编辑:我更新了代码,以显示我现在所拥有的内容,即当表单提交有错误时,如何将错误消息不放入我为错误所做的div内. /p>

更新的演示: http://jsfiddle.net/MtRn6/

解决方案

您需要使用errorPlacement将错误消息放在所需的位置,否则它将使用默认方法将错误消息附加到输入中:

// container is the element which should hold errors,
// You have already definied it in your demo
errorPlacement: function(error, element) {
        error.appendTo(container);
},

更新的演示: http://jsfiddle.net/MtRn6/1/

检查文档以获取更多信息: http://docs.jquery.com/Plugins/Validation /validate

I'm trying to use the following plugin wiht the second form where it places all the error messages inside of its separate div. Only difference is they place it above it and I'm placing mind below. However its still not displaying the messages inside the div for me. Not sure why.

http://jquery.bassistance.de/validate/demo/errorcontainer-demo.html

Demo: http://jsfiddle.net/xtremer360/KHSKm/1/

Edit: I updated my code want to show what I have now to how it's not placing the error messages inside of the div I have made for errors when there are errors for the form submission.

Updated Demo: http://jsfiddle.net/MtRn6/

解决方案

You need to use errorPlacement to put the error messages where you want them, otherwise it will use the default method of appending them to the input:

// container is the element which should hold errors,
// You have already definied it in your demo
errorPlacement: function(error, element) {
        error.appendTo(container);
},

Updated demo: http://jsfiddle.net/MtRn6/1/

Check the docs for more info: http://docs.jquery.com/Plugins/Validation/validate

这篇关于表格的错误放置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆