min, max and step Attributes
The min, max and step attributes are used to specify restrictions for input types containing numbers or dates.The max attribute specifies the maximum value allowed for the input field.
The min attribute specifies the minimum value allowed for the input field.
The step attribute specifies the legal number intervals for the input field (if step="3", legal numbers could be -3,0,3,6, etc).
Note: The min, max, and step attributes works with the following <input> types: date pickers, number, and range.
The example below shows a numeric field that accepts values between 0 and 10, with a step of 3 (legal numbers are 0, 3, 6 and 9):
Syntax
Points: <input type="number" name="points" min="0" max="15" step="5" />
Example
<!DOCTYPE html><html>
<body>
<form action="demo_form.asp" method="get">
Points: <input type="number" name="points" min="0" max="15" step="5"/>
<input type="submit" />
</form>
</body>
</html>
No comments:
Post a Comment