Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to validate a textbox for just numbers 1

Status
Not open for further replies.

bigfoot

Programmer
May 4, 1999
1,779
US
I'm looking for a validation expression that will allow a number in a textbox.

I tried this
ValidationExpression="[0-9]*\.[0-9]*"

But it makes me add the decimal and I want to be able to add an integer if I want.
And no spaces.

Any help would be great.
 
Try looking at for any Regular Expression issues. They have a "cheat sheet" which should explain how to do what you need.

You could also look into using a RangeValidator control if this is for validating data and you want to avoid a RegEx.


-------------------------------------------------------

Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]
[URL unfurl="true"]http://mdssolutions.co.uk[/url] - Delivering professional ASP.NET solutions
[URL unfurl="true"]http://weblogs.asp.net/marksmith[/url]
 
Thank you. I was out to that site but didn't see the cheat sheet.

I was so close.
FYI for others.
This:
ValidationExpression="[0-9]*\.?[0-9]*"

or This:
ValidationExpression="\d*\.?\d*"

This will allow multi decimal points - bad.
ValidationExpression="\d*\.*\d*"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top