html input type number min max code example
Example 1: html min max example input number
<input type="number" id="quantity" name="quantity" min="1" max="5">
Example 2: min number input html
<form action="/action_page.php">
<label for="myNumber">My Number:</label>
<input type="number" name="myNumber" id="myNumber" min="5" max="15">
<br><br>
<input type="submit" value="Submit">
</form>
Example 3: input type number max value validation
$(function () {
$( "input" ).change(function() {
var max = parseInt($(this).attr('max'));
var min = parseInt($(this).attr('min'));
if ($(this).val() > max)
{
$(this).val(max);
}
else if ($(this).val() < min)
{
$(this).val(min);
}
});
});
Example 4: number input html
<input id="number" type="number" value="42">