Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 222
  • Last Modified:

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
0
rito1
Asked:
rito1
  • 4
  • 2
1 Solution
 
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now