I have this code that prevents the user from entering negative weights in the Weight textbox.
<input type="number" min="0"
oninput="this.value = !!this.value && Math.abs(this.value)>= 0 ? Math.abs(this.value) : null">
Scenario 1 is working fine: Input: 1.23 Output 1.23
Scenario 2: Input: 0.05 Output 5 (I would like to get 0.05)
When I enter decimal numbers like 0.04 or 0.05, I am getting 4 or 5. I would like to get the decimal numbers as it is.