Javascript limit input to 2 decimal places code example
Example 1: input type that allows float number
<input type="number" step="0.01">
Example 2: js number 2 decimal places
(3.141596).toFixed(2);
Example 3: javascript show 2 decimal places
var myNumber=12.2345;
var myNumberWithTwoDecimalPlaces=parseFloat(myNumber).toFixed(2);
Example 4: javascript limit input to 2 decimal places
var validate = function(e) {
var t = e.value;
e.value = (t.indexOf(".") >= 0) ? (t.substr(0, t.indexOf(".")) + t.substr(t.indexOf("."), 3)) : t;
}