Solved

RequiredFieldValidator/RegularExpression

Posted on 2009-07-07
3
276 Views
Last Modified: 2012-05-07
Hi,

I need a requiredfieldValidator / regularExpressValidator which accepts only digits and it should accept
6 to 7 numbers typed in a textbox

for eg : 898838 (valid) or 9282798    (anything less than 6 or greater than 7 should throw error)


thanks in advance.
0
Comment
Question by:dotnet0824
  • 2
3 Comments
 
LVL 5

Assisted Solution

by:dumpsterdivingdave
dumpsterdivingdave earned 100 total points
ID: 24794726
0
 
LVL 3

Expert Comment

by:Michal-Drozd
ID: 24794744
try this:
<asp:RegularExpressionValidator ID="revPhoneNumber" runat="server" ControlToValidate="????" ErrorMessage="Enter Valid Number" ValidationExpression="[0-9]{6,7}"></asp:RegularExpressionValidator>

Open in new window

0
 
LVL 3

Accepted Solution

by:
Michal-Drozd earned 150 total points
ID: 24794788
I give you a little explanation for my above solution for better understanding:

Important is: ValidationExpression="[0-9]{6,7}"

this means to take only digits 0-9, and number of these digits is from 6 to 7
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
This video discusses moving either the default database or any database to a new volume.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

706 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now