wood burning stoves 2.0*
The moose likes HTML, CSS and JavaScript and the fly likes java script to validate decimal point Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "java script to validate decimal point" Watch "java script to validate decimal point" New topic
Author

java script to validate decimal point

Makhana Jiggu
Greenhorn

Joined: Nov 09, 2005
Posts: 11
I need to validate a field to allow only decimal values
eg 10.2 or 10.0 or 10 is acceptable
It can have only 2 digits before the decimal point and can have only one digit after the decimal point. How can i check this.
Any sample code is helpful


Jiggu
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
search for JavaScript regular expression with match and use this reg exp:

/\d{1,2}(.\d)?/

Eric
 
Consider Paul's rocket mass heater.
 
subject: java script to validate decimal point