开发者

Conditionally wrap error message in jQuery Validation

I need to wrap an error message only if a certain condition is true. This means I can't use the wrapper property since it would always wrap the error message. So I'm using errorPlacement() with the following code.

    errorPlacement : function(error, element) {开发者_如何转开发
        if (condition == true) {
            error.wrap("<li></li>").appendTo(element);
        }
        else {
            ...
        }
    }

Somehow this code doesn't have the message wrapped. First, am I right to replace errorPlacement() to get what I want done? Second, what am I doing wrong to wrap the HTML text?


Try $('<li></li>').append(error).appendTo(element);

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜