1、修改unhighlight方法:
unhighlight : function (e, i, s) {
"radio" === e.type ? this.findByName(e.name).removeClass(i).addClass(s) : t(e).removeClass(i).addClass(s);
if ($("[for=‘" + e.id + "‘]") && $(e).hasClass("valid")) {
$("[for=‘" + e.id + "‘]").hide();
}
}
2、添加获取绝对定位位置方法:
getAbsolutePos : function (el) {
var sl = 0,
st = 0;
if (el.scrollLeft && el.scrollTop) {
sl = el.scrollLeft;
st = el.scrollTop;
}
var r = {
x : el.offsetLeft - sl,
y : el.offsetTop - st
};
if (el.offsetParent) {
var tmp = this.getAbsolutePos(el.offsetParent);
r.x += tmp.x;
r.y += tmp.y;
}
return r;
},
3、添加滚动提示跟随滚动和隐藏提示方法
scrollLocation : function (vform) {
function getAbsolutePos(el) {
var sl = 0,
st = 0;
if (el.scrollLeft && el.scrollTop) {
sl = el.scrollLeft;
st = el.scrollTop;
}
var r = {
x : el.offsetLeft - sl,
y : el.offsetTop - st
};
if (el.offsetParent) {
var tmp = getAbsolutePos(el.offsetParent);
r.x += tmp.x;
r.y += tmp.y;
}
return r;
}
//滚动
var ct = document.body.scrollTop;
var ceng = $(this.currentForm).find(".in");
window.onscroll = function () {
var st = vform != "" ? document.body.scrollTop : 0;
var input = ceng.find("div > .error");
input.each(function (n) {
var p = getAbsolutePos(this);
var lt = 0;
if ($("[for=‘" + this.id + "‘]").text().length > 15) {
lt = 62
} else {
lt = 42;
}
$("[for=‘" + this.id + "‘]").css("top", (p.y + st - lt) + "px");
});