0 votes
1 view
in Web Technology by (22.4k points)

For <input type="number"> element, maxlength is not working. How can I restrict the maxlength for that number element?

1 Answer

0 votes
by (40.3k points)

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:

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...