JSFiddle - React, Tailwind, and code Playground
HTML
<form action="#">
<p>
<input class="toFixed1" type="text" placeholder="Type a number"></input>
</p>
<p>
<input class="toFixed1" type="text" placeholder="Type a number"></input>
</p>
<p>
<input class="toFixed1" type="text" placeholder="Type a number"></input>
</p>
<button id="submitform" type="submit">test</button>
</form>
JavaScript
//when user clicks submit button
$('#submitform').click(function(){
$(this).closest('form').find('.toFixed1').each(function(){
var val = parseFloat($(this).val());
//only perform operation on an actual number
if(!isNaN(val)){
//overwrite the value of the field with the reduced decimal number
$(this).val(val.toFixed(1));
}
})
})