Loading ...

How to validate max length of textbox text

0 (0votes)

Sometimes there can be a situation where we want to validate maximum length of a

textbox content.This can be done in many ways.

One way of doing it is through Regular Expression:

<asp:TextBox ID ="txtBox" runat="server"/>


Now,take the Regular expression validation control

<asp:RegularExpressionValidator ID="validateTextBox" runat="server"

Display="dynamic" ControlToValidate="txtBox" ValiadtionExpression="^([\S\s]{0,50})$">

Please,enter text less than 50 characters


Now,user can enter only 50 characters in the textbox.

Comments (no comments yet)

Top Posts