The estate maxlength doesn’t work if the type of input for "number". For this problem, a simple solution is to change the type to text.
<input class="searchInput" type="text" name="localizar" id="localizar" placeholder="numero do cliente" maxlength="10"/>
But if you need the type to be number for best use on mobile phones, you can use the type "tel" which will display a numeric keyboard and the maxlength will work the same way.
<input class="searchInput" type="tel" name="localizar" id="localizar" placeholder="numero do cliente" maxlength="10"/>
If for some reason you need to use the type "number", the solution will be with Javascript, where you should set the event oninput HTML to execute a function when the user inserts something into the text box. See the code below:
function maxLen(input) {
if (input.value.length > 10) {
input.value = input.value.slice(0, 10);
}
}
<input class="searchInput" type="number" name="localizar" id="localizar" placeholder="numero do cliente" oninput="maxLen(this)">
tried to use the attribute
maxin hisinput?maxlengthand generally used for thetype="text". If it is a mobile number, for example, change thetypefortext- https://www.w3schools.com/tags/att_input_type_number.asp– Cmte Cardeal
Thank you very much! Killed first! I switched the type by text ai the field accepted the maxlength.
– Adriano Ferreira