Answers for "return number with decimals and to digit in javascript"

14

js number 2 decimal places

(3.141596).toFixed(2);	// 3.14
Posted by: Guest on August-13-2020
1

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'));
Posted by: Guest on June-21-2021

Code answers related to "return number with decimals and to digit in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language