Link to home
Start Free TrialLog in
Avatar of zimmer9
zimmer9Flag for United States of America

asked on

I use the following RegularExpressionValidator to try and accept only alphanumeric characters but it allows special characters as well. Do you kow how I can fix this?

I am developing an ASP.NET application using C#.

I use the following RegularExpressionValidator to try and accept only alphanumeric characters.
However, the application accepts "Special Characters".
Do you know what I am doing wrong?

<asp:TextBox ID="txtaccountNum"  runat="server" Text='<%# Eval("accountNum") %>'></asp:TextBox>  
                       <asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" ControlToValidate="txtaccountNum" Display="Dynamic" ErrorMessage="Account # is required" SetFocusOnError="true" ForeColor="Red" ValidationGroup="AllValidators"></asp:RequiredFieldValidator>                  
                    <asp:RegularExpressionValidator ID="RegularExpressionValidator9" runat="server"
                           ErrorMessage="Enter alphanumeric characters only."
                           ControlToValidate="txtamount" ForeColor="#FF0066"
                           SetFocusOnError="true"
                           ValidationExpression="^[0-9a-zA-Z]+$">                  
                    </asp:RegularExpressionValidator>
ASKER CERTIFIED SOLUTION
Avatar of HainKurt
HainKurt
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial