File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Validating an Amount Field Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Validating an Amount Field" Watch "Validating an Amount Field" New topic
Author

Validating an Amount Field

Alec Lee
Ranch Hand

Joined: Jan 28, 2004
Posts: 569
I want to make sure a text field is any non-negative numeric value with 2 or less decimal point not less then say $100000. What is the simplest combination of the standard rules/regular expressions to achieve this with the validator?

Also, if I want to allow the user to optionally add commas like 10,000. What would the simplest combination of rules.

I guess the 'mask' rule has to be used with some regular expression. But my knowledge of regexpr is very little!

Thx for any advice.
Brent Sterling
Ranch Hand

Joined: Feb 08, 2006
Posts: 948
Here are some expressions that I put together a while ago. I tested them at the time and they have been in use for a few years so I hope they work. Like you, I don't know much about regular expressions, but I was smart enough to add a comment.


- Brent
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Validating an Amount Field
 
Similar Threads
Reg exp help?
Question about searching
Its urgent Higher Education In IT
I/O in Java
Conditional 'where' condition