The plugins site is currently in development.
We've been looking to provide a higher-quality, spam-free experience at the plugins site for some time, and a major error on our part forced us to shut down the current site before we could put the new one in place. We are developing a new site, and you can follow along with its development on GitHub. For more information about this transition, including steps you can take as a plugin author to prepare, please read our post about what's going on.
jQuery Form Validation and Tooltip(S.Sams)
updated by jquery-tooltip_20091007!
Demo: http://www.cnblogs.com/S.Sams/archive/2008/08/07/tooltip.html
Example:
/*
S.Sams Lifexperience
-----------------------------------------------------
Copyright (C) 2002 - 2008 S.Sams Lifexperience!
All rights reserved
Email: Cassams(#)gmail.com / S.Sams(#)msn.com
WebSite: Http://lab.travelive.com.cn/
Msn: S.Sams(@)Msn.com
Author: Sam Shen
*/
(function($) {
$.fn.tooltip = function(options){
var getthis = this;
var opts = $.extend({}, $.fn.tooltip.defaults, options);
$('body').append('<div class="tooltipshowpanel"></div>');
$(document).mouseover(function(){$('.tooltipshowpanel').hide();});
this.each(function(){
// Tooltip
if($(this).attr('tip') != undefined)
{
$(this).hover(function(){
$('.tooltipshowpanel')
.css({left:$.getLeft(this)+'px',top:$.getTop(this)+'px'});
$('.tooltipshowpanel').html($(this).attr('tip'));
$('.tooltipshowpanel').fadeIn("fast");
},
function(){
$('.tooltipshowpanel').hide();
});
}
if($(this).attr('reg') != undefined)
{
$(this).focus(function(){
$(this).removeClass('tooltipinputerr');
}).blur(function(){
if($(this).attr('toupper') == 'true')
{
this.value = this.value.toUpperCase();
}
var thisReg = new RegExp($(this).attr('reg'));
if(thisReg.test(this.value))
{
$(this).removeClass('tooltipinputerr').addClass('tooltipinputok');
}
else
{
$(this).removeClass('tooltipinputok').addClass('tooltipinputerr');
}
});
}
});
if(opts.onsubmit)
{
$('form').submit( function () {
var isSubmit = true;
getthis.each(function(){
var thisReg = new RegExp($(this).attr('reg'));
if(!thisReg.test(this.value))
{
$(this).removeClass('tooltipinputok').addClass('tooltipinputerr');
isSubmit = false;
}
});
return isSubmit;
} );
}
};
$.extend({
getWidth : function(object) {
return object.offsetWidth;
},
getLeft : function(object) {
var go = object;
var oParent,oLeft = go.offsetLeft;
while(go.offsetParent!=null) {
oParent = go.offsetParent;
oLeft += oParent.offsetLeft;
go = oParent;
}
return oLeft;
},
getTop : function(object) {
var go = object;
var oParent,oTop = go.offsetTop;
while(go.offsetParent!=null) {
oParent = go.offsetParent;
oTop += oParent.offsetTop;
go = oParent;
}
return oTop + $(object).height()+ 5;
},
onsubmit : true
});
$.fn.tooltip.defaults = { onsubmit: true };
})(jQuery);
(function($){
$(document).ready(function(){
$('select[tip],select[reg],input[tip],input[reg],textarea[tip],textarea[reg]').tooltip();
});
})(jQuery);
