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 Android Security Essentials Live Lessons this week in the Android 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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java script to validate decimal point
 
Similar Threads
How to count the number of digits after decimal point in java?
Regular Expression Help
validte amount with javascript?
Displaying data from right to left in a textbox
validation of input field