0

What do I have to change if only numbers from 0 to 99 should be allowed?

<input type="text" style="text-align:center" NAME="name" pattern="[0-99]" size="1" maxlength="2">

Now only numbers from 0 to 9 can be entered.

MattC
  • 3,984
  • 1
  • 33
  • 49
vossmalte
  • 174
  • 2
  • 2
  • 16
  • of course it is in a
    – vossmalte Feb 07 '14 at 15:48
  • Possible duplicate of [How can I limit possible inputs in a HTML5 "number" element?](http://stackoverflow.com/questions/8354975/how-can-i-limit-possible-inputs-in-a-html5-number-element) – Pekka Nov 27 '16 at 11:26

4 Answers4

4

You will want to use min and max and also set it as a type of number.

E.g

<input type="text" style="text-align:center" type="number" NAME="name" min="0" max="99" size="1" maxlength="2">

Read more about it here.

Ryan McDonough
  • 9,732
  • 3
  • 55
  • 76
2
<input type="text" style="text-align:center" type="number" NAME="name" min="0" max="99" size="1" maxlength="2">
ediblecode
  • 11,701
  • 19
  • 68
  • 116
1

The regular expression for matching numbers 0 to 99 is "[0-9]?[0-9]"

Michael Hagar
  • 626
  • 5
  • 20
0

Demo

With regex:

<form action="demo.php">
  <input type="text" name="xxxxx" pattern="^([0-9][0-9]?|)$">
  <input type="submit">
</form>
daniel__
  • 11,633
  • 15
  • 64
  • 91