as title

解决方案 »

  1.   

    function checkTextLength(obj,length)
            {
              if(obj == null)
              {
                    window.alert("脚本错误,参数不正确");
                    //用法:<asp:textbox onkeypress="checkTextLength(this,30);" onblur="checkTextLength(this,30);" TextMode="MultiLine">
              }
              else
              {
                    if(obj.value.length>length-1)
                    {
                        if(event.keyCode==0)
                            window.alert("请确保文本框输入的内容最大长度为"+length+"个字符,超出部分将自动截断");
                        obj.value = obj.value.substring(0,length-1);
                    }
              }      
            }
      

  2.   

    string a;
    a=textBox.Text;
    a.Length;