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

只愿长相守 提交于 2020-01-06 13:45:06

问题


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. The number of inputs I have is variable so I cannot do that.


回答1:


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
  2. use javascript to capture the submit event and inspect the form state. Either prevent submit and move focus to the next field or allow the submit event to continue based on the form state.


来源:https://stackoverflow.com/questions/15556739/barcode-scanner-and-input-fields-replace-new-line-call-to-tab-call

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!