Horje
How to create HTML step Attribute in input

The input step attribute specifies the legal number intervals for an input field.

Example: if step="3", legal numbers could be -3, 0, 3, 6, etc.

Tip: This attribute can be used together with the max and min attributes to create a range of legal values.

The step attribute works with the following input types: number, range, date, datetime-local, month, time and week.


How is to look HTML step Attribute in input

An input field with a specified legal number intervals:
index.html
Example: HTML
 <form>
  <label for="points">Points:</label>
  <input type="number" id="points" name="points" step="3">
</form> 

Output should be:

How is to look HTML step Attribute in input

Full Code Example of HTML step Attribute in input

The input step attribute The step attribute specifies the legal number intervals for an input element.
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The input step attribute</h1>

<p>The step attribute specifies the legal number intervals for an input element.</p>

<form action="/action_page.php">
  <label for="points">Points:</label>
  <input type="number" id="points" name="points" step="3">
  <input type="submit" value="Submit">
</form>

</body>
</html>

Output should be:

Full Code Example of HTML step Attribute in input

Note: Input restrictions are not foolproof, and JavaScript provides many ways to add illegal input. To safely restrict input, it must also be checked by the receiver (the server)!





Category:
Web Tutorial
Sub Category:
HTML Input Attributes
Uploaded by:
Admin


Read Article
https://develop.horje.com/learn/1434/reference