troubleshooting Question

ASP.Net RegularExpression Validators

Avatar of WebAppDeveloper
WebAppDeveloperFlag for United States of America asked on
ASP.NETRegular Expressions
3 Comments1 Solution7 ViewsLast Modified:

I am looking for a regular expression that validates to ensure that a min. of 2 and max. of 8 alpha characters (including spaces) are allowed without counting any leading and trailing spaces. Following regular expression doesn't seem to work (see ValidationExpression below).  Could someone please tell me what am I missing and provide a correct regex for this?

<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="txtProductName" CssClass="ErrorMessage" Display="Dynamic" ValidationExpression="^[^\s]+[a-zA-Z\s]{2,8}[^\s]+$" ErrorMessage="Minimum 2 and maximum 8 characters allowed." SetFocusOnError="True" />

Many thanks in advance.

Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 3 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros