Summary -
In this topic, we described about the Number Input type with detailed example.
The "number" input type specifies a field for entering a number only. It represents the field for a number input. <input> tag uses the following attributes to specify restrictions -
- max - specifies the maximum value allowed
- min - specifies the minimum value allowed
- step - specifies the legal number intervals
- value - Specifies the default value
Syntax -
<input type="number" min=”minimum-value” max=”maximum-value”
value=”initial-value” step=”legal-number” >
Example -
Below example explains how to set number input type.
<!DOCTYPE html>
<html lang="en">
<body>
<form action="form-results.php">
<label for="mymonth">Enter Month -</label>
<input type="number" min=1 max=12 value=1 id=”mymonth”>
<button type="button" >Submt</button>
</form>
</body>
</html>
Output-
Browser Support
The following browsers and corresponding versions in the table that completely supports the month type.
Input Type | Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
Type="month" | 8 and above | 9 and above | 13 and above | 5 and above | 11 and above |