我需要一个脚本,该脚本可以让我在当前输入达到10个字符时将焦点(或setactive)更改为下一个输入
我正在为项目尝试此操作,我想知道一旦到达键盘上输入的(n)个字符数后如何动态改变文本输入的焦点
<body>
<input type=text id="inp1" placeholder="Nombre" onfocus="changeInput();" />
<br/>
<input type=text id="inp2" placeholder="Apellidos" onfocus="changeInput();" />
<br/>
<input type=text id="inp3" placeholder="Dni" onfocus="changeInput();" />
<br/>
<input type=text id="inp4" placeholder="Direccion" onfocus="changeInput();"/>
<br/>
<input type=button value="Enviar" />
</body>
function changeInput() {
let inpt1 = document.getElementById("inp1").value.length;
let inpt2 = document.getElementById("inp2");
if(inpt1 == 10){
inpt2.setactive();
}
}
我猜我的主要问题是我正在应用该函数的事件,但是在阅读了元素文档之后,我找不到正确的方法。针说我是编码新手