i have a regular expression on ASP.net textbox control that validate for user input it should be only letters and numbers within 6 to 200 character
this is my code
<asp:TextBox ID="txtCategory_description" runat="server" Style="width: 485px;" Height="70px"
TextMode="MultiLine"></asp:TextBox>
<asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ErrorMessage="Invalid Category name"
ValidationExpression="^[a-zA-Z0-9._-]{6,200}$" ControlToValidate="txtCategory_description"
Display="None"></asp:RegularExpressionValidator>
the problem is where i wrote in the textbox any HTML code like it accept it and send me to error page of
can any one help me ??
note : on my page i have another regular expressions if i left all of them wrong , that regular expression also work well , the problem appear if it is only the wrong one
^([\-a-zA-Z0-9\._]){6,200}$Just as @user1428799 said, you need the 200, not 15.
That should do it. Correct me if I’m wrong, but the hyphen needs to be placed in front (immediately after the [ otherwise it’s treated as a range character.
Edit
You can also just escape it as you may have to do so with the dot as well.