如何使用jquery验证插件查看顶部标签的特定消息?
我正在使用 jquery 验证插件在顶部而不是标签旁边显示错误消息。比如说,我有地址、城市、邮政编码...如果用户不输入任何内容,我必须在 div 顶部显示错误消息,例如“请输入有效地址”、“请输入有效城市”等。 。 我如何覆盖插件的默认行为......任何帮助将不胜感激...... 谢谢!
I am using jquery validation plugin to display error message in the top instead instead of beside the labels. say, i have address , city, zip code ....if user don't enter anything i have to display the error message at top in a div like " please enter valid address" , "please enter valid city" etc...
how can I override the default behavior of the plugin .....any help will be appreciated ...
thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
errorLabelContainer
和wrapper
选项 为此:errorLabelContainer
确定添加错误元素的位置,wrapper
确定它们所包装的内容。在本例中#someElementUpTop
是一个,用于将
包装标签附加到...因此单击仍会转到页面中存在验证错误的正确元素。如果您需要在此之上的另一个元素,例如在存在/不存在错误时适当隐藏和显示的
,请添加一个
errorContainer:“ #someDiv"
选项。You can use
errorLabelContainer
andwrapper
options for this:errorLabelContainer
determines where the error elements are added,wrapper
determines what they're wrapped in. In this case#someElementUpTop
is a<ul>
to append the<li>
wrapped labels to...so clicking still goes to the correct element in the page that has the validation error. If you need another element above this, say a<div>
that hides and shows appropriately when there are/aren't errors, add aerrorContainer: "#someDiv"
option as well.