<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>textarea的控制,包括数字,blur focus</title>
</head>
<style type="text/css">
</style>
<script src="js/jquery-1.3.2.min.js" type="text/javascript"></script>
<script>
jQuery(function(){
jQuery.fn.autoHeight=function(_e){
var $=jQuery;
return this.each(function(){
if($(this).is("textarea")){
if($.browser.msie&&$.browser.version=="6.0"){
$(this).css("overflow-y","visible");
}else{
var _10=this;
var _11=["keyup","focus","blur"];
$.each(_11,function(i,n){
$(_10).bind(n,function(){
$(this).css("height",0).css({"height":Math.max(this.scrollHeight,_e)});
});
});
}
}
});
};
jQuery.fn.limitLength=function(_7,_8){
var $=jQuery;
return this.each(function(){
if($(this).is("input:text")||$(this).is("textarea")){
var _a=this;
var _b=["keyup","focus","blur"];
$.each(_b,function(i,n){
$(_a).bind(n,function(){
if(this.value.length>_7){
this.value=this.value.substring(0,_7);
}
if(_8){
$(_8).html((this.value==$(this).data("tooltip")?0:this.value.length)+"/"+_7);
}
});
});
$(this).triggerHandler("blur");
}
});
};
/*jQuery.fn.tooltip=function(_1,_2,_3){
alert("fd");
var $=jQuery;
return this.each(function(){
if($(this).is("input:text")||$(this).is("textarea")){
$(this).focus(function(){
var _5=$.trim(this.value);
if(_5==""||_5==_1){
$(this).val("").css(_2||{color:"#333333"});
}
}).blur(function(){
var _6=$.trim(this.value);
if(_6==""||_6==_1){
$(this).val(_1).css(_3||{color:"#888888"});
}
}).data("tooltip",_1).triggerHandler("blur");
}
});
};*/
$("form[name=messageForm] textarea[name=message]").limitLength(140,"#messageLength").autoHeight(42).focus(function(){
$(this).css("borderColor","#F9B967");
}).blur(function(){
$(this).css("borderColor","");
}).keydown(function(e){
if(e.ctrlKey&&e.keyCode==13){
$(this.form).triggerHandler("submit");
return false;
}
});
})
</script>
<body>
<div id="messageLength">140</div>
<div id="productWrap">
<form action="#" method="get" name="messageForm">
<div class="status-text">
<input type="text" style="display: none;" value="0" name="gid">
<input type="text" style="display: none;" value="0" name="cid">
<input type="submit" class="post-btn" value="留言">
<textarea autocomplete="off" name="message" style="color: rgb(51, 51, 51); height: 35px;"></textarea>
</div>
</form>
</div>
</body>
</html>
loading