Numeric Value and possibly including decimal values (.)

Hi All,

I am wanting to use ASP.Net's RegularExpressionValidator control for a form field that should only allow numeric values including decimal values.

Please could any provide the Regular expression statement for this?

Many thanks,

Rit
LVL 1
rito1Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

kuknoCommented:
^[\+\-]*\d+\.{0,1}\d*$
kuknoCommented:
to test it use: http://www.fileformat.info/tool/regex.htm

Cheers
Kurt
kuknoCommented:
Oops, wrong number of +/- possible.

Correct one: ^[\+\-]{0,1}\d+\.{0,1}\d*$

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Exploring ASP.NET Core: Fundamentals

Learn to build web apps and services, IoT apps, and mobile backends by covering the fundamentals of ASP.NET Core and  exploring the core foundations for app libraries.

rito1Author Commented:
Excellent, many thanks.. love the testing tool too!
ddrudikCommented:
You could shorten that pattern to:
^[+-]?\d+\.?\d*$
kuknoCommented:
That's correct, however the pattern itself is the same when transformed to an internal state engine. So, there is no performance benefit, it's just a shorter definition string.
ddrudikCommented:
I don't have performance testing that shows a benefit either way, I just was noting there was a shorter way to display that.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Regular Expressions

From novice to tech pro — start learning today.