Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

regular Expression validator:To limit the number of words in a textbox

Posted on 2009-04-24
6
Medium Priority
?
458 Views
Last Modified: 2012-06-21
hi all,
i used regular Expression validator, to limit the number of words a user can enter.
but If i enter even 2 words. its throwing me an error.
can you please check and tell me whats wrong?

thanks

<asp:RegularExpressionValidator ID="RegExValActivity" runat="server" ControlToValidate="TxtActionItems" ErrorMessage="Please limit words 1000 or less."
ValidationExpression="(((^\s*)*\S+\s+)|(\S+)){1,10}" Display="none" Validationgroup="Travel" ></asp:RegularExpressionValidator>
<cc1:ValidatorCalloutExtender ID="ValixtenderActionItems" runat="server" TargetControlID ="RegExValActivity"/>

Open in new window

0
Comment
Question by:SaraDob
  • 4
  • 2
6 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 24228642
What about:
\b{0,100}

Open in new window

0
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
ID: 24228657
Actually, let me alter that a bit:
(?:\w+\b){0,1000}

Open in new window

0
 
LVL 1

Author Comment

by:SaraDob
ID: 24228968
Thanks...Worked well...
 
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:SaraDob
ID: 24228985
Hey a small error..
can you please complete this ValidationExpression="(((^\s*)*\S+\s+)|(\S+)) {1,1000)
wher i insert this (?:\w+\b){ is it after  \S+))?
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 24229098
That should have been the whole expression. Does it not work by itself?
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 24229283
Ok. I tested this and it should be what you need--the entire expression. (I forgot to include space-checking in the last one!)
ValidationExpression="(?:\w*\b\s?){0,1000}"

Open in new window

0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses
Course of the Month13 days, 3 hours left to enroll

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question