software
software

Reputation: 728

how to validate a textbox length in vb.net?

In VB.NET , I am trying to validate a

<asp:textbox id="name" runat=server> </asp:textbox>

textbox value which should not exceed more than 200 characters and the textbox takes only string.

Which validator will be a good option ? i want to use custom validator, will it work with string values?

Upvotes: 1

Views: 3716

Answers (2)

Steve
Steve

Reputation: 216273

You can avoid the use of custom validator altogether.
If you only need to force the max length of a text box field you have this at your disposal

<asp:TextBox MaxLength="200" id="name" runat=server> </asp:TextBox> 

Upvotes: 0

Yaqub Ahmad
Yaqub Ahmad

Reputation: 27659

 <asp:RegularExpressionValidator ID="regexTextBox1"
 ControlToValidate="YourTextBoxID" runat="server" 
 ValidationExpression="^[\s\S]{0,200}$" Text="200 characters max" />

Upvotes: 1

Related Questions