0

I try like this :

<input type="number" pattern="[1-9]*" class="form-control" min="1">

I try input dot, it can

How can I disable dot(.) and another?

So, only 1-9

moses toh
  • 12,344
  • 71
  • 243
  • 443

2 Answers2

2

The same way you have min, you can add max=9:

<input type="number" class="form-control" min="1" max="9">

You will need to have some custom JavaScript validation (there are libraries for that) to interpret the min and max attributes for those browsers which do not support them natively.

Ionică Bizău
  • 109,027
  • 88
  • 289
  • 474
  • It does not work. If I input dot(.), it can. It should not be input dot(.) – moses toh Oct 06 '17 at 08:59
  • @Ionica, can you check [my question](https://stackoverflow.com/questions/47833540/figure-not-rotating-as-expected#47833540) when you have time? It is about a game that you have developed. I couldn't contact you anywhere else, sorry. – Snow Dec 15 '17 at 13:43
0

You can also use the pattern attribute in html5:

<input type="text" name="name" pattern="[0-9]" title="Title" />
Cerbrus
  • 70,800
  • 18
  • 132
  • 147
Anish Varghese
  • 3,450
  • 5
  • 15
  • 25