jQuery 验证插件 - 如何在错误时更改 css
我正在关注这里的演示
http://jquery.bassistance.de/validate/demo/marketo /
提交表单时,如果该字段为空,输入框和其他字段如何获得红色边框?我必须在我的插件减速中添加什么才能得到它?
更新
$("#profile_form").validate({
rules: {
nickname: "required",
address: "required"
},
messages: {
nickname: "(required)",
address: " (required)"
}
});
我知道如何通过css获取边框,我需要知道验证插件如何更改css。
问候
I am following the demo over here
http://jquery.bassistance.de/validate/demo/marketo/
On submitting the form, if the field is empty, how are the input boxes and other fields getting that red border around them? What is it I have to add in my plugin decleration to get that?
Update
$("#profile_form").validate({
rules: {
nickname: "required",
address: "required"
},
messages: {
nickname: "(required)",
address: " (required)"
}
});
I know how to get the border via css, I need to know how is the validate plugin changing the css.
Regards
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这就是我完成我正在寻找的东西的方法...
使用 jquery.validate 插件中的
highlight
和unhighlight
选项可以解决问题。This is how I accomplished what I was looking for...
Using the
highlight
andunhighlight
options in the jquery.validate plugin does the trick.像这样的东西就可以做到...
CSS
在这种情况下,Firebug 是你的朋友。
Something like this will do it...
CSS
In this case, Firebug is your friend.
您可以将
blur()
事件处理程序附加到输入框。在回调函数中,您将检查输入的内容,然后使用css()
相应地更改 css。例子:
You would attach a
blur()
event handler to the input box. In your callback function, you would check the contents of the input then change the css accordingly usingcss()
.Example: