• js代码小记(判断textbox的长度,并且固定最多收入字符)


    <!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=300;//允许多少字符串填入

    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;
      }
     else {
      remainingchars_el.innerHTML 
    = "<font color=red>" +
      (
    -num_remaining + '') + " characters over</font>";
      }

    }

    function isOver(sText)
                
    {
                    
    var intlen=sText.value.length;
                    
    if (intlen>testleng)
                    
    {
                        alert(
    "描述特征的内容的字数必修小于或者等于 "+testleng);
                        sText.focus();
                        sText.select();
                    }

                }


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

    <body>
    <<B>Group description</B><BR><TEXTAREA id=desc onkeydown=GC_UpdateCharCount() onkeyup=GC_UpdateCharCount()  onblur="isOver(this);"style="WIDTH: 99%" name=desc rows=4 cols=50></TEXTAREA> 
                
    <BR>Letters remaining: <SPAN id=remainingchars>
                
    <SCRIPT language=javascript1.2><!--
                  GC_UpdateCharCount();
                  
    //--></SCRIPT></SPAN><NOSCRIPT>300 characters allowed </NOSCRIPT>
    </body>
    </html>
    效果参考:www.lostfound.cn/CoutChar.html
  • 相关阅读:
    Webwork【04】Configuration 详解
    Webwork【03】核心类 ServletDispatcher 的初始化
    Webwork【02】前端OGNL试练
    Webwork【01】Webwork与 Struct 的前世今生
    Oracle 数据库日常巡检
    php jquery ajax select 二级联动【get方式】
    PHP+ajax实现二级联动【post+json方式】
    thinkphp中在页面怎么格式输出小数和时间
    DataTables Bootstrap 3 example
    Bootstrap表格动态加载内容和排序功能
  • 原文地址:https://www.cnblogs.com/xucanzhao/p/420594.html
Copyright © 2020-2023  润新知