Recently, I made a jquery.validate bubble prompt in my project.
It seems that the latest version of jquery.validate has this function, but it doesn’t work well for me.
I just added one myself.
I found some plug-ins qtip2 with good styles, but I can’t display them locally. He also has an example of jquery.validate. But the style is not displayed here. It seems to be the jquery version of asking him, and it can be displayed using his jquery. You can't cheat with mine. give up.
poshytip-1.1, the style is not bad!
positionX, positionY is the position where the prompt is displayed.
$(document).ready(function () {
// validate the comment form when it is submitted
var myForm = $('form:first');
myForm.validate({
onkeyup: false,
success: function (element ) {
var elem = $(element);
elem.poshytip('disable');
elem.poshytip('destroy');
},
errorPlacement: function (error , element) {
var elem = $(element);
if (!error.is(':empty')) {
//right: x=right;y=center
/ /Left: x=left;y=center
//Top: x=inner-left
//Bottom: x=center;y=bottom
var aX = "center";
if (elem.attr("positionX") != null) {
aX = elem.attr("positionX");
}
var aY = "bottom";
if (elem.attr ("positionY") != null) {
aY = elem.attr("positionY");
}
elem.filter(':not(.valid)').poshytip({
content: error,
alignTo: 'target',
alignX: aX,
alignY: aY,
offsetX: 0,
offsetY: 5
});
} else {
elem.poshytip('disable');
elem.poshytip('destroy');
}
}
});
});
There is a problem onkeyup cannot be true, because in this case, some verification bubbles will always exist. This is unscientific. Does anyone have any good ideas?