随笔-5  评论-22  文章-35  trackbacks-0

<DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>Untitled Document</title>
<SCRIPT language=javascript1.3><!--
var testleng=30;//允许多少字符串填入
function GC_UpdateCharCount() {
  var desc_el = document.getElementById('desc');
  var remainingchars_el = document.getElementById('remainingchars');

  var num_remaining = testleng - desc_el.value.length;

  if (num_remaining >= 0) {
  remainingchars_el.innerHTML = num_remaining;
  document.getElementById('num').style.display = "";
  } else {
  document.getElementById('num').style.display = "none";
  remainingchars_el.innerHTML = "超出的字数:&nbsp;" + "<font color=red>"+
  (-num_remaining + '') + "</font>";
  }
}
function isOver(sText)
            {
                var intlen=sText.value.length;
                if (intlen>testleng)
                {
                    alert("描述特征的内容的字数必修小于或者等于 "+testleng);
                    sText.focus();
                    sText.select();
                }
            }

//--></SCRIPT>
</head>

<body>
<TEXTAREA id=desc onkeydown=GC_UpdateCharCount() onkeyup=GC_UpdateCharCount()  onblur="isOver(this);" name=desc rows=4 cols=40></TEXTAREA>
            <BR><table><tr><td  id="num">还剩下的字数:</td><td><SPAN id=remainingchars>
            <SCRIPT language=javascript1.2><!--
              GC_UpdateCharCount();
              //--></SCRIPT></SPAN></td></tr></table>
</body>
</html>

posted on 2006-07-24 11:21 fish的Blog 阅读(313) 评论(0)  编辑  收藏 所属分类: JavaScript

只有注册用户登录后才能发表评论。


网站导航: