Basically, I have a number input field on my page, and I want users to be able to insert only 4 digits into the field. I know I can do something like this:
<input type="number" max="9999">
But the browser will check the correctness of the input only when I click the "send" button. I want to say: let's say that the user enters “1234” into the field, and then tries to dial “1” or any other number. I want him to not be able to do this. Basically, when he continues to press any of the buttons / letters, I want them to just not appear in the field.
How can i achieve this?
source
share