1. js 如何實現輸完了一個文本框後再自動換下一個文本框,文本框裡面的值不限定大小。
function _autochange(len,th){
if(th.value.length==len)
{
var next = th.nextSibling.nextSibling;
next.focus();
}
}
這是我以前寫的一個類似的東西 不知道是不是你想要的。
其中參數len代表你要輸入多少個字元才換,th你傳個this就可以了
因為那時候有三個並列的框,我需要輸入一個然後跳下一個的 就寫了個這個通用
2. java怎樣讓焦點在按下回車鍵後自動跳到下一個文本框
import java.applet.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class Text extends Applet implements ActionListener {
TextField userText, passText;
Button loginButton;
public void init() {
userText = new TextField(10);
passText = new TextField(10);
loginButton = new Button("login");
add(userText);
add(passText);
add(loginButton);
userText.addActionListener(this);
passText.addActionListener(this);
}
public void actionPerformed(ActionEvent e) {
if (e.getSource() == userText)
passText.requestFocus();
else if (e.getSource() == passText)
loginButton.requestFocus();
}
}
也可用鍵盤事件keyListener介面實現keyPress()方法
當if(event.keyCode==13) 設置焦點
3. js 文本框回車後,游標移動到下一個文本框
window.event 時間 監聽 是否按回車了 然後 調用回車的 函數