Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

validate decimal number with 6 decimal digits javascript

var regexp = /^d+(.d{1,2})?$/;

console.log("'.74' returns " + regexp.test('.74'));
console.log("'7' returns " + regexp.test('7'));
console.log("'10.5' returns " + regexp.test('10.5'));
console.log("'115.25' returns " + regexp.test('115.25'));
console.log("'1535.803' returns " + regexp.test('1535.803'));
console.log("'153.14.5' returns " + regexp.test('153.14.5'));
console.log("'415351108140' returns " + regexp.test('415351108140'));
console.log("'415351108140.5' returns " + regexp.test('415351108140.5'));
console.log("'415351108140.55' returns " + regexp.test('415351108140.55'));
console.log("'415351108140.556' returns " + regexp.test('415351108140.556'));
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #validate #decimal #number #decimal #digits #javascript
ADD COMMENT
Topic
Name
5+5 =