0

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.

1
  • The spinbox control of HTML5 doesn't provide restrictions on input values of you input values directly through number keys, the range will be taken care of only when spin buttons are pressed, instead, you should make restrictions using JavaScript. Commented Mar 23, 2011 at 10:57

2 Answers 2

3

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.

Sign up to request clarification or add additional context in comments.

Comments

0
<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>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.