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*$
0
kuknoCommented:
to test it use: http://www.fileformat.info/tool/regex.htm

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

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

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
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

rito1Author Commented:
Excellent, many thanks.. love the testing tool too!
0
ddrudikCommented:
You could shorten that pattern to:
^[+-]?\d+\.?\d*$
0
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.
0
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.
0
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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.