我想你也打開資源庫中的issue?
那裏總結一下我的反應,使用change
回調與switchInput
API函數來完成你所需要的(demo):
HTML(例如)
<input type="text" /> <!-- max len = 3 -->
<input type="text" /> <!-- max len = 3 -->
<input class="last" type="text" /> <!-- max len = 4 -->
腳本
$(function() {
$("input").keyboard({
position: {
// position under center input
of: $("input:eq(1)"),
// move down 12px; not sure why it doesn't line up
my: 'center top+12',
at: 'center top'
},
enterNavigation: true,
maxLength: 4,
layout: 'num',
autoAccept: true,
usePreview: false,
change: function(e, keyboard, el) {
var len = keyboard.$el.hasClass("last") ? 4 : 3;
if (keyboard.$el.val().length >= len) {
// switchInput(goToNext, isAccepted);
keyboard.switchInput(true, true);
} else if (keyboard.$el.val() === "" && keyboard.last.key === "bksp") {
// go to previous if user hits backspace on an empty input
keyboard.switchInput(false, true);
}
}
});
});
我認爲你沒有將任何事件綁定到輸入字段。另外,如果時間爲0,則不需要調用'setTimeout()'函數。 – Samir
你可以給我jsfiddle演示嗎? @薩米爾 –