Click here to Skip to main content
12,997,190 members (76,870 online)
Rate this:
 
Please Sign up or sign in to vote.
See more:
I need a regular expression that checks a numeric value to ensure it has two decimal places after the ".".

eg. 0.01, 0.10 is OK, but 2.0 or 0.1 is not OK.

It's for use with currency. However, I don't need to worry about the $ sign.
Posted 2-Feb-12 6:57am
Updated 2-Feb-12 7:23am
v2

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Try this:

/\d*\.\d{2}/

I rephrased your question so I hope this is what you were after/
  Permalink  
Comments
cutexxbaby 2-Feb-12 13:32pm
   
but i try the expression you give, however , it give me dont allow me 0.01, 0.10 is which i want it to be OK

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.170622.1 | Last Updated 2 Feb 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100