简体   繁体   English

条形码扫描仪和输入字段,将新的线路呼叫替换为选项卡呼叫?

[英]Barcode scanner and input fields, replace new line call to tab call?

So barcode scanners end each scan with a carriage return, which messes up forms by submitting them. 因此,条形码扫描仪会以回车符结束每次扫描,而回车符则会通过提交表格来弄乱表格。 Is it possible to change this so that it calls a tab instead (thus moving to the next input field)? 是否可以更改此名称,使其改为调用选项卡(从而移至下一个输入字段)?

I did a find a solution here that does that, but it manually focused on each input using their id's. 我在这里找到了一个可以做到这一点的解决方案,但是它使用ID手动关注每个输入。 The number of inputs I have is variable so I cannot do that. 我拥有的输入数量是可变的,所以我不能这样做。

Yes, it is possible. 对的,这是可能的。 There are 2 ways: 有两种方法:

  1. reprogram the barcode reader to send the TAB key instead of a carriage return after reading a barcode 重新编程条形码阅读器以在读取条形码后发送TAB密钥而不是回车
  2. use javascript to capture the submit event and inspect the form state. 使用javascript捕获Submit事件并检查表单状态。 Either prevent submit and move focus to the next field or allow the submit event to continue based on the form state. 要么阻止提交,然后将焦点移到下一个字段,要么允许提交事件根据表单状态继续。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM