I am new to JS and HTML and I have a form. In the input fields I get number (%). I need to store it as "have a precision of decimal (4,2)
". Is there a solution using HTML? This is want I'm trying to do:
- If the number is 1 to store it as 1.00.
- If the number is 1.23 store as it is.
- If the number is 1.12345 store as 1.12
- If the number is 1.2 store as 1.20
- If the number is empty store 0.00
In the value I display the value from the DB, and 0.00 if nothing in DB. However the problem is when I press save and it sent to the DB. Is there a solution? I am using MySQL DB Using laravel
<div class="d-flex" style="display: flex;">
<input type="number" name="fee_ctv_omp_percent" id="fee_ctv['omp_percent']" value="{{$fee_ctv['omp_percent'] ?? '0.00'}}" class="w-100" step="0.1" max="100" style="border:none;">
<span class="table-control-addon-right">%</span>
</div>