Solved

RequiredFieldValidator/RegularExpression

Posted on 2009-07-07
3
277 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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)…
In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

910 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