How to control that when the input box exceeds a certain number of characters, you can't continue to enter it.

problem description

After the

input box exceeds a certain number of characters, you can"t continue typing. You can"t use maxlength, to ask for advice.

the environmental background of the problems and what methods you have tried

related codes

/ / Please paste the code text below (do not replace the code with pictures)

what result do you expect? What is the error message actually seen?

Dec.24,2021

< input type= "text" maxlength= "10" placeholder= "can only enter 10 characters" / >


maxlength


the input box will trigger an event when the content changes, so that you can check the character length in the input box in real time and restrict input. Remember to consider compatibility. The reference link is as follows:
https://www.cnblogs.com/littl.


<input type="text" oninput="if(value.length>5)value=value.slice(0,5)" />
Menu