Is it possible to add a decimal on a number input, as a user types?
I have the below input:
<div class="form-control">
<label for="bill">Bill</label>
<input
type="number"
id="bill"
name="bill"
placeholder="0"
maxlength="6"
/>
And I want it to look like the below as I type:
I've tried to set the input.value and wrap it in formatter.format()
, using the below, but I get a parsing error. Because of the $ sign and it being a number input, I'm guessing.
let formatter = new Intl.NumberFormat('en-US', {
style: 'currency',
currency: 'USD', });
Is there anyway to do this?