简体   繁体   English

条形码阅读器标签,然后输入

[英]Barcode reader tab then enter

I am trying to work out a way of making A return function as a tab or vice versa. 我正在尝试找出一种使制表符为return函数的方法,反之亦然。 When the user scans the barcode it moves to the next text field then on the last field it submits the form. 当用户扫描条形码时,它将移至下一个文本字段,然后在最后一个字段中提交表单。 Really of sure of this and jquery/ JavaScript to make it happen! 确实可以做到这一点,并通过jquery / JavaScript实现!

The default behavior of barcode scanners is to input the characters followed by "enter." 条形码扫描仪的默认行为是输入字符,然后输入“ enter”。 If you meant you want the scanner to move to the next field instead, you can block the enter with something like: 如果您想让扫描仪移至下一个字段,则可以使用以下命令阻止输入:

<form method="post">
<input type="text" name="barcode" id="b1" />
<input type="text" name="otherfield" id="b2" />
<input type="submit" id="submit" />
</form>
<script type="text/javascript">
$('#b1').keydown(function(e){
    if (e.keyCode == 13) { // barcode scanned!
        $('#b2').focus();
        return false; // block form from being submitted yet
    }
});
</script>

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

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