请教各位,如何限制文本框中输入的字数啊?当该文本框中的字数达到50个字(包括标点时),自动弹出提示框提示字数已到50,文本框中也不能再输入任何字符,要怎么实现啊?请教高手帮忙!
解决方案 »
- 有关SQL注入与try.catch问题
- 求 C#实现统计视图控件。实现饼状 思路和源码!
- SendMessage控制添加ListView32中Item应该如何做?
- 200高分求winform应用的c#控制扫描仪的实现方法
- 数据库设计的时间默认值不等于我输入的!为什么。
- 求 VSS 8.0 中文版下载
- C#的最爱,欢迎各位加入C#专区。大家互相学习,享受c#带来的革命
- 调用解决方案另一个项目中的方法时,方法中的ConfigurationManager.ConnectionStrings["ConnStr"]是null
- 在C#中怎样使用GDI?
- 菜鸟寻:水晶报表CrystalReportViewr的使用实例!
- ClickOnce问题
- ado.net entity connectionString如何配置
应该行了吧?
{
if(this.tb1.MaxLength>=50)
MessageBox.Show("Length >= 50!");
}
var maxChars = 20;
if (which.value.length > maxChars)
which.value = which.value.substring(0,maxChars);
var curr = maxChars - which.value.length;
}
</script>
<asp:TextBox ID="txtInput" runat="server" Width="200px" Height="60px" onkeydown="checkLength(this);" TextMode="MultiLine"></asp:TextBox>MaxLength
{
if(this.tb1.Text.Trim().Length>=50)
MessageBox.Show("Length >= 50!");
}
private void tb1_TextChanged(object sender, EventArgs e)
{
if(this.tb1.Text.Length>=50)
MessageBox.Show("Length >= 50!");
}
改成this.tb1.text.length>=50
试下吧
MessageBox.Show("大于50");
之后在tb1的keyup时间中添加
if(this.tb1.MaxLength>=50)
MessageBox.Show("Length >= 50!")试试行不