473,385 Members | 1,325 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

ValidationExpression for a single number

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>

Nov 28 '05 #1
3 3896
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" <to*******@gmail.com> wrote in message
news:11*********************@g14g2000cwa.googlegro 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>

Nov 28 '05 #2
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: PL****@PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

"TD" <to*******@gmail.com> wrote in message
news:11*********************@g14g2000cwa.googlegro 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>

Nov 30 '05 #3
TD
SWEET ! Thanks Peter and Patrick

Nov 30 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: JIM.H. | last post by:
ValidationExpression="\d{2}/\d{2}/\d{4}" how can you make this work for date exactly. Taking care of Feb for example?
1
by: CoreyMas | last post by:
Hello Everyone I am in search of a ValidationExpression that will detect if a user has entered Script or HTML code inside of a textbox. Or in the very least look for an expression that detects...
0
by: Andy Eshtry | last post by:
I have a radio button list, a textbox representing SIN or EIN based on my radio button list selection so I put 2 regularexpressionvalidator to evaluate the value of textbox. EIN must be (for...
3
by: skardian | last post by:
I am currently using the ChangePassword control for ASP.NET 2.0 to allow users to update or change their password as need be. However I am running into a problem with the Regular Expression...
2
by: Nathan Sokalski | last post by:
As we probably know, the MaxLength property of the TextBox control only works when the TextMode property is SingleLine or Password. I want to limit the number of characters a user can enter into a...
0
by: Morten71 | last post by:
I have this regex. in the ValidationExpression property of my dotnet 1.1 RegularExpressionValidator control: ^(?i)(DF)?+$ However, I can't make the ignore case part (?i) work! How should I...
3
by: lukkynivas | last post by:
Hi, this is CNU ,can any body let me know what is the validationexpression for following criteria my text should contain At least one digit,6 to 12 chars and underscore i gave like (\w*+\w*) but...
5
by: Matt Nunnally | last post by:
I'm trying to get my zip code textbox to validate both US zip codes and Canadian Postal code formats. But I can't figure out the syntax. Can somebody help? Here is what I got: ...
1
by: J055 | last post by:
Hi I've having trouble getting this expression to work in both javascript and server side. (?:^.+\.)(?i-msnx:((jpg)|(gif)))$ I'd like to apply a ValidationExpression which is case...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.