开发者

xVal: How to get error message to show up underneath field rather than beside it?

Using xVal with Jquery validation and would like the error messages to be shown underneath the field rather than besides it. 开发者_JS百科Is this possible?

Also, is it possible to instruct xVal to simply show a "*" next to the field and then show the actual error message in a tooltip and/or summary above the form?

Thanks


For the placing of the error message. You can use a span tag like this one. Place it as a sibling after the field it should hold the error message for. Check this xVal source (xVal.jquery.validate.js) for details if you want

<span class='field-validation-error'></span>


This code from xVal source associate message output to tag, that placed below field. I want to view message above field. How I can to do this?

_associateNearbyValidationMessageSpanWithElement: function(element) {
            // If there's a <span class='field-validation-error'> soon after, it's probably supposed to display the error message
            // jquery.validation goes looking for an attribute called "htmlfor" as follows
            var nearbyMessages = element.nextAll("span.field-validation-error");
            if (nearbyMessages.length > 0) {
                $(nearbyMessages[0]).attr("generated", "true")
                                    .attr("htmlfor", element.attr("id"));
            }
        },
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜