my dog learned polymorphism*
The moose likes HTML, CSS and JavaScript and the fly likes Simple regular expression! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Simple regular expression!" Watch "Simple regular expression!" New topic
Author

Simple regular expression!

Jeppe Sommer
Ranch Hand

Joined: Jan 07, 2004
Posts: 270
I want to use regular expression to test if a price (decimal) has the correct format:

Now I�m allowed to type in a positive integer with 2 decimals, i.e. 15.50.

Script:
document.form1.productPrice.value.match(/^\d+(\.\d{2})?$/)

I also want to be able to type in a positive integer with 1 decimal only!

Have can I do that?
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
{1,2}
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Simple regular expression!
 
Similar Threads
The regular expression to parse �(abc.3, d.42), (cde.2, 3)�
RegExpr to Add Comma and Decimal Points
use regular expression to check date format in javascript
how to operate on big Integer?
Needed help in composing an regular expression