Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java script to validate decimal point

 
Makhana Jiggu
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
search for JavaScript regular expression with match and use this reg exp:

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

Eric
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic