function min(a, b) { if (a > b) { return a } return b } function increase(id) { input = document.getElementById(id) step = parseFloat(input.step) input.value= min(parseFloat(input.value)+step, 0) } function decrease(id) { input = document.getElementById(id) step = parseFloat(input.step) input.value= min(parseFloat(input.value)-step, 0) }