ValidationExpression for a single number

T

TD

Is it possible to validate (or in this case, invalidate) an exact
number with a RegularExpressionValidator?

I know that it can be done with javascript but what about regular
expressions?

Any 5 digit number between 00000 and 99999 is ok EXCEPT 61280.

I'm handling the "any 5 digits" portion with this "^\d{5}$" .... Does
anyone know how to disallow 61280 ?

Thanks, TD

<asp:RegularExpressionValidator
ValidationExpression=""
Runat="server"
ControlToValidate="txtsubacct_no"
ErrorMessage="61280 is not valid"
Display="Dynamic"
ID="regexV1">
</asp:RegularExpressionValidator>
 
P

Peter Blum

You don't need a regular expression for this.

Instead, use a RangeValidator with Type=Integer, Min=0 and Max=99999.
Then add a CompareValidator with ValueToCompare=61280, Type=Integer,
Operator=NotEquals

--- Peter Blum
www.PeterBlum.com
Email: (e-mail address removed)
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top