This question has already been answered:
It is necessary to check if the length does not exceed 10 elements.
I use getElementById , but it doesn't work, what's the problem?
Plus, it rechecks only what you typed on the keyboard, and how to make an additional input check at the touch of a button?
function checkLength() { var input = document.getElementById("t"); { if (input.value.length == 10) { input = input.replace(input, ''); alert("Only 10 numers"); } } } <input type="text" maxlength="10" name="answer" id="t" onkeyup="isAllowedSymbol(this);checkLength();" placeholder="Enter data">
maxlengthproperty no longer gives input of more than 10 characters, what else is needed? - user207618