How to put decimal (1.0 and 1.10) in step="0.010" of a field type = number? I have already tried to do but always the zeros are left out, it is not possible to make a 1.60 height eg result is always 1.6.
How to put decimal (1.0 and 1.10) in step="0.010" of a field type = number? I have already tried to do but always the zeros are left out, it is not possible to make a 1.60 height eg result is always 1.6.
0
to the right of the decimals):
document.getElementById("input").addEventListener("change", function(){
this.value = parseFloat(this.value).toFixed(2);
});
document.getElementById("input").addEventListener("change", function(){
this.value = parseFloat(this.value).toFixed(2);
});
<input id="input" type="number" step="0.010" />
Or with jQuery:
$("input").on("change",function(){
$(this).val(parseFloat($(this).val()).toFixed(2));
});
$("input").on("change",function(){
$(this).val(parseFloat($(this).val()).toFixed(2));
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><inputid="input" type="number" step="0.010" />