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.

Example

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>
<html>
   <head>
      <title>HTML input step attribute</title>
   </head>

   <body>
      <form action = "" method = "get">
         <input type="number" name="points" step="5"><br>
         <input type="submit" value="Submit">
      </form>
   </body>
</html>
raja
Published on 23-Jan-2018 08:55:14
Advertisements