如何在多行文本框中不允许超过最大长度和特殊字符 [英] How to Not allow more than maximum length and special characters in multiline textbox

查看:197
本文介绍了如何在多行文本框中不允许超过最大长度和特殊字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个多行的文本框,所以默认的maxlength不起作用,我怎么能克服这个问题,它不应该允许比maxlength更多的字符,也不应该允许该文本框中的特殊字符

解决方案

对于maxlength,您可以使用 TextChanged 事件并计算其中的字符数。如果char count是最大块用户输入char或删除最后输入的char。



如果不允许使用特殊字符:AjaxControlToolKit'的 FilteredTextBoxExtender

< asp:FilteredTextBoxExtender ID =fteDaterunat =serverTargetControlID =txtBeginDateValidChars =0123456789- /。>< / asp:FilteredTextBoxExtender> 





祝你好运,

OI


I am having a text box which is multiline so the default maxlength doesnot work, how can i overcome this such that it should not allow more characters than maxlength and also should not allow special characters in that textbox

解决方案

For maxlength you can use TextChanged event and count the characters there. If the char count is the max block user to enter the char or delete the last entered char.

For not allowing special characters use: AjaxControlToolKit''s FilteredTextBoxExtender

<asp:FilteredTextBoxExtender ID="fteDate" runat="server" TargetControlID="txtBeginDate" ValidChars="0123456789-/."></asp:FilteredTextBoxExtender>



Good luck,
OI


这篇关于如何在多行文本框中不允许超过最大长度和特殊字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆