Input Type Number
Input type="number" represents a control that allows the user to enter numbers into an input element.
type="number" places a control on the input element. These controls are:
- The user will be able to enter the input element number but not the string.
- Spaces cannot be used in the number entry field.
- The user cannot enter floating-point numbers. To get floating-point numbers from the user, you must use the step attribute. Floating-point numbers must be valid in this field.
- The user can leave the input element empty and can change it.
Example
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<form>
<label for="quantity">Quantity</label>
<input type="number" id="quantity">
<input type="submit" value="Submit">
</form>
</body>
</html>
