0๐
โ
Iโve used this method in my project to format the value on input. The key is using .toFixed(2)
to force 2 decimal places:
formatFixedDecimal(value) {
const numValue = typeof value === "string" ? parseFloat(value) : value; // Ensure Number
return numValue.toFixed(2); // Two decimal places
}
Source:stackexchange.com