Reputation: 347
I want to restrict entry of input onto a field of type number such that input cannot be outside range of min-max specified in the html.
input type = "number" min = "1" max = "5"
Is there a way of outputting the number field without the text box and i would rather not use
"input type = range"
as slider does not show value currently selected
Please help.
Thanks.
Upvotes: 0
Views: 9154
Reputation: 1009
<form>
Only 1 to 100 <input type="text" name="number" pattern="\d{1,2}(?!\d)|100" title="one to hundreed only">
<input type="submit">
</form>
Upvotes: 0
Reputation: 18870
Based on what you said, I suggest using a simple input text field and check it's value validity on submission via JavaScript (as @Kush mentions above). You could also check it as the user types, or moves focus away from that field.
Upvotes: 3