You can just add the max attribute this will specify the highest possible number that you can insert
<input type="number" max="999" />
But, if you add both a max and a min value you can specify the range of allowed values:
<input type="number" min="1" max="999" />
The above code will still not stop you from manually entering a value outside of the specified range.
Instead you can display a popup telling it to enter a value within this range upon submitting the form as shown in this screenshot: