0

I am trying to set the minimum number of characters for a textbox, and if the user input dos not reach the set minimum an error must show, In i was trying to do just that using <asp:RegularExperssionValidator> but the error message is nit showing, what am i missing or doing wrong?

<asp:TextBox ID="TextBox2" runat="server" CssClass="form-control"></asp:TextBox> 
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" 
    ErrorMessage="ID length is Less than 10" ControlToValidate="TextBox2" ValidationExpression=".{10}.*">
</asp:RegularExpressionValidator>

                `
2
  • Add ^ and $ characters and try it like this "^[.]{10}$" Also Display="Static" or Dynamic if you don't use ajax callout extenders Commented Nov 7, 2016 at 7:36
  • Try this /.{10,}/ Commented Nov 7, 2016 at 7:39

1 Answer 1

2
<asp:TextBox ID="TextBox2" runat="server" CssClass="form-control"></asp:TextBox> 
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" 
ErrorMessage="ID length is Less than 10" ControlToValidate="TextBox2" ValidationExpression="^[a-zA-Z0-9]{10,1000}$">
</asp:RegularExpressionValidator>
  <br />
  <asp:Button ID="Button1" runat="server" Text="Button" />
Sign up to request clarification or add additional context in comments.

2 Comments

try this @SibusisoShongwe
I assume this is the Range {10,1000}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.