troubleshooting Question

ASP.Net RegularExpression Validators

Avatar of Bobby X
Bobby XFlag for United States of America asked on
Regular ExpressionsASP.NET
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.

David H.H.Lee
Digital Marketing (Hospitality)
Log in to continue reading
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform for $9.99/mo
View membership options
Unlock 1 Answer and 3 Comments.
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
The Value of Experts Exchange in My Daily IT Life

Experts Exchange (EE) has become my company's go-to resource to get answers. I've used EE to make decisions, solve problems and even save customers. OutagesIO has been a challenging project and... Keep reading >>


Owner of Outages.IO
Phoenix, Arizona, United States
Member Since 2016
Join a full scale community that combines the best parts of other tools into one platform.
Unlock 1 Answer and 3 Comments.
View membership options
“All of life is about relationships, and EE has made a virtual community a real community. It lifts everyone's boat.”
William Peck

Member since 2004