jQuery validate - 如何删除特定错误消息而不删除任何其他错误消息?
参见:jsFiddle
我试图仅删除当从选择列表“角色”中选择“外部”的不同选项时,会出现特定错误消息(“选择部门”),因为仅当用户角色是“外部”我需要指定该用户属于哪个部门。
我只能使用 removeClass("error")
删除错误样式,但即使在删除该类之后,错误消息仍然显示,并且只有在我尝试删除时才会消失提交表单,但这不是我想要的,我想要做的是让错误消息(“选择部门”)消失一旦选择另一个用户角色(当然,与“外部”不同的角色)
为了让你更容易理解我,我贴了一个 jsFiddle。
我真的希望你能帮助我
See: jsFiddle
I'm trying to remove only a specific error message ("Select a department"), when a different option to "External" is selected from the select list "Role", since only when a user role is "External" I need to specify which department that user belongs to.
I've only been able to remove the error style using removeClass("error")
, but even after I've removed that class, the error message is still display and it only disappears if I attempt to submit the form and that's not what I want, what I want to do is to make that error message ("Select a department") disappear as soon as another user role is selected(a role different to "external" of course)
In order for you to understand me more easily I have put up a jsFiddle.
I really hope you can help me out
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需在禁用选择的行后面添加
department.next().hide();
即可。请参阅此。Just add
department.next().hide();
after the line that disables the select. See this.