条形码读取器选项卡,然后输入



我正在尝试解决一种将返回函数作为选项卡做出的方法,反之亦然。当用户扫描条形码时,它将移至下一个文本字段,然后在最后一个字段上提交表单。真的可以确定这一点和jQuery/javaScript可以实现它!

条形码扫描仪的默认行为是输入字符,其后是" Enter"。如果您意味着要扫描仪转移到下一个字段,则可以用以下内容阻止Enter。

<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>

相关内容

最新更新