Skip to content

VALIDATION OF THE TEXTBOX

george wambui

Asked Mar 28, 2012, 8:44 PM EDT1 answer
Share
LinkedInX
HI Team,

Can someone please help with the validation of the textbox on the length of the text to be accepted by the textbox and also the datatype which is typed in the textbox should that the textbox should not accept char when only integer is required or visa verse.




Thanks & regard

george

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • Senthilkumar
    0
    Hi,

    You can restrict the textbox length by setting the property.

     MaxLength="250 

    It will restrict the user to enter with in 250 characters. But the text box mode of number or any other thing is out of box.
    But the visual studio 11 have the different modes in textbox.

    You can use the regular expression to validate.

    <asp:TextBox ID="TextBox1" runat="server" Style="z-index: 100; left: 259px; position: absolute;
    top: 283px" ValidationGroup="check"></asp:TextBox>

    <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="TextBox1"
    ErrorMessage="Please Enter Only Numbers" Style="z-index: 101; left: 424px; position: absolute;
    top: 285px" ValidationExpression="^\d+$" ValidationGroup="check"></asp:RegularExpressionValidator>
    0