How do we include the legal number intervals for an input field in HTML?


Use the step attribute to include the legal number intervals for an input field in HTML. 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 implement step attribute −

<!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>

Updated on: 03-Mar-2020

212 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements