Is there\'s any way to format an input[type=\'number\'] value to always show 2 decimal places?
Example: I want to see 0.00 instead of
If you landed here just wondering how to limit to 2 decimal places I have a native javascript solution:
Javascript:
function limitDecimalPlaces(e, count) {
if (e.target.value.indexOf('.') == -1) { return; }
if ((e.target.value.length - e.target.value.indexOf('.')) > count) {
e.target.value = parseFloat(e.target.value).toFixed(count);
}
}
HTML:
Note that this cannot AFAIK, defend against this chrome bug with the number input.