开发者

jQuery validate -How do I remove a specific error message without removing any other error messages?

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 rem开发者_JAVA技巧oved 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


Just add department.next().hide(); after the line that disables the select. See this.

...
role.change(function() {
    if (role.val()=="EU"){
        ...
    } else{
        department.removeClass("error");
        department.attr("disabled", true);    
        department.next().hide();
        $("#password").focus();
    }
});
...
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜