Click here to Skip to main content
15,881,455 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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
Posted

1 solution

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
 
Share this answer
 
v2
Comments
sagarjainhr 7-Mar-13 9:18am    
This asp filter will work on click event but I want the textbox should inform dynamically or should not take that element at all
Orcun Iyigun 7-Mar-13 9:57am    
It should work dynamically not just on click event. I think there is something wrong on your implementation. Also have a look at this page: Numbers and Characters only Textbox Validation in C# ![^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900