クライアントは、請求書番号 (5 桁) と「Enter」キーストロークを含むバーコードをスキャンする必要があります。
「Enter」キーを無視して、5 文字後の次の入力ボックスにフォーカスを移動するには、入力ボックスが必要です。
サンプルコードを含めていただければ幸いです。ありがとう!
クライアントは、請求書番号 (5 桁) と「Enter」キーストロークを含むバーコードをスキャンする必要があります。
「Enter」キーを無視して、5 文字後の次の入力ボックスにフォーカスを移動するには、入力ボックスが必要です。
サンプルコードを含めていただければ幸いです。ありがとう!
テキスト ボックスの onkeypress または onkeyup を使用し、コード if(event.keyCode==13)return false; を追加します。(13 はエンター キー) 次のコントロールにフォーカスを設定します。
たとえば、2 つのテキスト ボックス (TxtBox1 と TxtBox2) があるとします。
<input id="TxtBox1" type="submit" onkeypress="if(event.keyCode==13)return false;document.getElementById('TxtBox2').focus(); " name="Submit" value="Send" />
$('input[type=text]').on('keyup', function(e) {
if (e.which != 27 || e.which != 8) { // check for backspace and delete
if (e.which != 13) { // ignoring enter
if (!this.value.replace(/\s/g, '').match(/\d/g)) { // checking for digit
alert('Insert Digit');
$(this).val(''); // make the field empty
} else {
if (this.value.length > 4) {
$(this).next().focus(); // automatically change current input of length 5 digits
}
}
}
}
});
いくつかの JQuery:
$('#test').keydown(function(e) {
if (e.which == 13) {
if ($(this).val().length == 5) {
e.preventDefault();
$('#test2').focus();
}
}
});
「test」と「test2」が 2 つのテキスト ボックスの ID であると仮定します。
エンターキーを無視する代わりに、物事を進めるための合図として使用してください。次のようなもの:
$("#myTextbox").keydown(function(event){
if(event.keyCode == 13){
// validate input and move on to the next textbox
}
});