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

642 views Asked by At

Using xVal with Jquery validation and would like the error messages to be shown underneath the field rather than besides it. 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

2

There are 2 answers

0
jitter On BEST ANSWER

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>
0
xelibrion On

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"));
            }
        },