Im trying to display error messages for the jquery validator plugin(the bassistance one) as a tooltip above the component when the validation fails. The tooltip(also the bassistance one) just wont show, so I was wondering how to get this stuff working. My code so far:
$("#loginForm").validate({
errorPlacement: function(error, element) {
$(element).tooltip({
content: 'the error message goes here'
});
}
});
Also, I was wondering how I can get hold of the actual localised error message to display. I do not want to hardcode it into the tooltip as I’ve done in the snippet above.
Any help is much appreciated! 😉
One way for doing this (without tooltip plugin) is with some off css code and some of imagination:
Instead of only a label for errors i create this html for errors:
With css code we are going to hide this labels to the user. But the errorImage is always visible (when the element is created, of course). And, when the user hover over it, the label will show:
And for making the tooltips visible out of the bounds of its parents you must change the parent’s overflow property to visible. If you are using jQueryUI see the css for making those changes.
And this is how it looks:
Edit: Created JSFiddle for demonstration, updated
onfocusoutmethodhttps://jsfiddle.net/2vc5vmr0/