How to use input type field with steps in HTML?

HTMLWeb DevelopmentFront End Technology

The HTML input type step attribute sets the legal number intervals. Steps are number steps like 0, 5, 10, 15, 20, etc. The step attribute can be used together with the max and min attributes to create a range of legal values.


You can try to run the following code to create a step of numbers with the input step attribute. Here, we are creating a step 5, so the valid input will be 5, 10, 15, 20, etc.

On entering a number except that and pressing submit button, the following message will be visible: “Please enter a valid value”. It will also let you know the two nearest values.

<!DOCTYPE html>
      <title>HTML input step attribute</title>

      <form action = "" method = "get">
         <input type="number" name="points" step="5"><br>
         <input type="submit" value="Submit">
Updated on 14-May-2020 08:42:00