Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 794 Vote(s) - 3.53 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to limit the number of characters allowed in a textbox?

#1
<asp:TextBox ID="txtBodySMS" runat="server" Rows="10"
TextMode="MultiLine" Width="100%"></asp:TextBox>

This is my text box. How do I limit the number of characters a user can type inside it?
Reply

#2
MaxLength="Int32"

<asp:TextBox ID="txtBodySMS" runat="server" Rows="10" MaxLength="220"
TextMode="MultiLine" Width="100%"></asp:TextBox>

Reply

#3
Set the MaxLength attribute to the number of characters.
Reply

#4
AFAIK maxlength has never worked in conjunction with the "multiline" mode. Therefore I would suggest some client-side js/jquery and server-side to get around the problem.
Reply

#5
You are looking for MaxLength: Look [here](

[To see links please register here]

)
Reply

#6
Have you tried setting the MaxLength Property on the TextBox? for [Reference](

[To see links please register here]

)
Reply

#7
Add an extender of type FliterTextBoxExtender for your text box
it should appear like that

<asp:TextBox ID="TxtCellular" runat="server"></asp:TextBox>
<asp:FilteredTextBoxExtender ID="TxtCellular_FilteredTextBoxExtender"
runat="server" Enabled="True" TargetControlID="TxtCellular" FilterType="Numbers">
</asp:FilteredTextBoxExtender>
Reply

#8
Maximum character length Validation (Maximum 8 characters allowed)

<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:RegularExpressionValidator Display = "Dynamic" ControlToValidate = "TextBox1" ID="RegularExpressionValidator1" ValidationExpression = "^[\s\S]{0,8}$" runat="server" ErrorMessage="Maximum 8 characters allowed."></asp:RegularExpressionValidator>



Minimum character length Validation (Minimum 8 characters required)

<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<asp:RegularExpressionValidator Display = "Dynamic" ControlToValidate = "TextBox2" ID="RegularExpressionValidator2" ValidationExpression = "^[\s\S]{8,}$" runat="server" ErrorMessage="Minimum 8 characters required."></asp:RegularExpressionValidator>



Minimum and Maximum character length Validation (Minimum 5 and Maximum 8 characters required)


<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
<asp:RegularExpressionValidator Display = "Dynamic" ControlToValidate = "TextBox3" ID="RegularExpressionValidator3" ValidationExpression = "^[\s\S]{5,8}$" runat="server" ErrorMessage="Minimum 5 and Maximum 8 characters required."></asp:RegularExpressionValidator>

Reply

#9
It is important to note that using `MaxLength` alone (with no other properties to add, just like the other answers) works ONLY for projects in .NET Framework 4.5 and above.

I'm using 4.5, and it worked for my project

<asp:TextBox ID="txtSample" MaxLength="3" runat="server"/>

[TextBox.MaxLength Property (MSDN Documentation)][1]


[1]:

[To see links please register here]

Reply

#10
Just type below two line in .cs page load

textbox1.Attributes.Remove("MaxLength");
textbox1.Attributes.Add("MaxLength", "30");

Hope it will help !
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through