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.
Who is Participating?
Michal-DrozdConnect With a Mentor Commented:
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
dumpsterdivingdaveConnect With a Mentor Commented:
try this:
<asp:RegularExpressionValidator ID="revPhoneNumber" runat="server" ControlToValidate="????" ErrorMessage="Enter Valid Number" ValidationExpression="[0-9]{6,7}"></asp:RegularExpressionValidator>

Open in new window

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.