on-internet
← Community

RegularExpressionValidator for US phonenumber ASP.net

Stack Overflow ·

I am having an issue using the RegularExpressionValidator using Visual Studio 2010. This is my code: <asp:Label ID="phone" runat="server" Text="Phone Number"></asp:Label><asp:TextBox ID="phonebox" runat="server" TextMode="Phone"></asp:TextBox> <asp:RegularExpressionValidator ID="RegularExpressionValidator3" runat="server" ErrorMessage="Invalid Number" ControlToValidate="phonebox" ValidationExpression="((\(\d{3}\) ?)|(\d{3}-))?\d{3}-\d{4}"></asp:RegularExpressionValidator> <br /> No matter what number I type in, I get an error message beside the field - even if I copy and paste a valid US phone

Comments

Sign in or sign up to comment and upvote.

No comments yet.