Basically, I have a number input field on my page, and I want users to only be able to insert 4 digits in the field. I know I can do something like this:
<input type="number" max="9999">
But the browser is going to check if the input is correct only when I press the "submit" button. What I want to do is : Let's say that the user types "1234" in the box, and after that he tries to type "1" or any other number. I want him to not be able to do that. Basically when he keeps pressing any of the buttons/letters, I want them to simply not appear in the box.
How can I achieve this?