2

Is it possible to have an input element with type equal to number, whose arrow buttons would change the value not by step attribute, but by other given number?

I need to have a field with step equal to .001, buy I'd like to make +-1 jumps by clicking arrows. (I ask aboout native arrow buttons, of course I can simulate them anyhow, but that's not the question.)

Serge Seredenko
  • 3,541
  • 7
  • 21
  • 38

1 Answers1

-1

googling turned this up first

<input type="number" name="points" min="0" max="100" step="0.001" value="30">

Other than that, I guess you'll need to use JS to manipulate the behaviour. Maybe sth like:

<input id="example" type="number" name="points" step="0.001" onchange="checkChangedInput();">
<script>
  function checkChangedInput() {
    // check if number got lower or higher
    ...
    document.getElementById("example").value += OldValuePlusZeroPointNineNineNine;
</script>

Though I guess using onchange might give unexpected results when sth is being typed in the field. So you should also check if in/decrement was more than your step(0.001).

This might yield some useful information as well: HTML5 input type=number change step behavior

Community
  • 1
  • 1
chris_blues
  • 129
  • 9