By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,659 Members | 1,678 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,659 IT Pros & Developers. It's quick & easy.

String Validation

P: 21
Hello:

I am trying to validate the length of a string in a text box.

I just need the string to be between 1 - 50.

I have tried RangeValidation and RegularExpressionValidation and everytime I go to test the Validator fires even though the string is in the acceptable range.

Below is the code for my check, both Range and Reg. Ex.

Thanks in advance for your help.

Expand|Select|Wrap|Line Numbers
  1. <td>
  2.                             <asp:TextBox ID="FNameTextBox" runat="server" Text='<%# Bind("FName") %>' />
  3.                         </td>
  4.                         <td>
  5.                             <asp:RangeValidator ID="RangeValidator1" runat="server" 
  6.                                 ControlToValidate="FNameTextBox" ErrorMessage="First Name Too Long" 
  7.                                 MaximumValue="25" MinimumValue="1"></asp:RangeValidator>
  8.                         </td>
  9.  
Expand|Select|Wrap|Line Numbers
  1. <td>
  2.  <asp:TextBox ID="FNameTextBox" runat="server" Text='<%# Bind("FName") %>' />
  3.                         </td>
  4.                         <td>
  5.                             <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" 
  6.                                 ControlToValidate="FNameTextBox" ErrorMessage="First Name Too Long" 
  7.                                 ValidationExpression="^[a-zA-Z0-9]{25}"></asp:RegularExpressionValidator>
  8.                         </td>
  9.  
Apr 2 '12 #1
Share this Question
Share on Google+
1 Reply


P: 21
Sorry. This is actually a ASP.NET issue. Not ASP classic.
Apr 2 '12 #2

Post your reply

Sign in to post your reply or Sign up for a free account.