Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ValidationExpression for a single number

Reply
Thread Tools

ValidationExpression for a single number

 
 
TD
Guest
Posts: n/a
 
      11-28-2005
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>

 
Reply With Quote
 
 
 
 
Patrick.O.Ige
Guest
Posts: n/a
 
      11-28-2005
TD try looking through :-
http://www.regexlib.com
It should be able to guide you to match your patter.
Also see this for reference at :- http://regex.osherove.com/
Hope that helps
Patrick

"TD" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
> 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>
>



 
Reply With Quote
 
 
 
 
Peter Blum
Guest
Posts: n/a
 
      11-30-2005
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: http://www.velocityreviews.com/forums/(E-Mail Removed)
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

"TD" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
> 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>
>



 
Reply With Quote
 
TD
Guest
Posts: n/a
 
      11-30-2005
SWEET ! Thanks Peter and Patrick

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ignore case ValidationExpression in RegularExpressionValidator Morten71 ASP .Net 0 04-02-2007 12:28 PM
ValidationExpression that simulates the MaxLength property Nathan Sokalski ASP .Net 2 01-03-2007 07:30 AM
ValidationExpression Error skardian@gmail.com ASP .Net 3 11-17-2006 08:55 PM
ValidationExpression =?Utf-8?B?SklNLkgu?= ASP .Net 4 11-18-2004 05:45 PM
ValidationExpression Syntax =?Utf-8?B?T2xpdmVyIFNjaHVsemU=?= ASP .Net 0 05-12-2004 02:06 PM



Advertisments