min max in input type number code example
Example 1: min length input html
<form action="/action_page.php">
<label for="password">Password:</label>
<input type="password" id="password" name="password" minlength="8"><br><br>
<input type="submit" value="Submit">
</form>
Example 2: html min max example input number
<input type="number" id="quantity" name="quantity" min="1" max="5">
Example 3: html restrict input to numbers
<input type="text" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" />
Example 4: input type number max value validation
/* comman function for all input by joshi yogesh {[email protected]} */
$(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 5: number input html
<input id="number" type="number" value="42">