zoukankan      html  css  js  c++  java
  • 对用户输入内容进行字数提示功能

    第一步:以下是核心代码,在页面引用或进行封装都可。

    <script language="javascript" type="text/javascript">        

      function textLimitCheck(thisArea, maxLength, SpanId)        

      {

      if (thisArea.value.length > maxLength)            

      {                 

      thisArea.value = thisArea.value.substring(0, maxLength);                

      thisArea.focus();            

      }            

      /*回写span的值,当前填写文字*/   

      var varss='(剩余字数:'+(maxLength-thisArea.value.length)+')';       

      document.getElementById(SpanId).innerHTML =varss;        

      }    

      </script>

    第二步:文本框应用此函数

    <asp:TextBox ID="txtOwner_Name" runat="server" Width="250px" MaxLength="50"  onkeyup="textLimitCheck(this,50,'spOwner_Name')" BackColor="Info"></asp:TextBox>

    <span id="spOwner_Name" style="color: gray"><em>(50字以内)</em></span> 

  • 相关阅读:
    线段树(updata+query)
    铁轨(栈)
    困难的串(搜索)
    素数环(简单搜索)
    编码
    opencv + numpy for python
    PIL参考手册
    八数码问题
    三维地图(BFS)
    梯田(dfs)
  • 原文地址:https://www.cnblogs.com/zcttxs/p/2546369.html
Copyright © 2011-2022 走看看