String Validation

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • billybob206
    New Member
    • Jun 2009
    • 21

    String Validation

    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 RegularExpressi onValidation 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.

    Code:
    <td>
                                <asp:TextBox ID="FNameTextBox" runat="server" Text='<%# Bind("FName") %>' />
                            </td>
                            <td>
                                <asp:RangeValidator ID="RangeValidator1" runat="server" 
                                    ControlToValidate="FNameTextBox" ErrorMessage="First Name Too Long" 
                                    MaximumValue="25" MinimumValue="1"></asp:RangeValidator>
                            </td>
    Code:
    <td>
     <asp:TextBox ID="FNameTextBox" runat="server" Text='<%# Bind("FName") %>' />
                            </td>
                            <td>
                                <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" 
                                    ControlToValidate="FNameTextBox" ErrorMessage="First Name Too Long" 
                                    ValidationExpression="^[a-zA-Z0-9]{25}"></asp:RegularExpressionValidator>
                            </td>
  • billybob206
    New Member
    • Jun 2009
    • 21

    #2
    Sorry. This is actually a ASP.NET issue. Not ASP classic.

    Comment

    Working...