仅允许从条形码扫描仪输入文本框并限制键盘的任何输入 [英] allow textbox input from barcode scanner only and restrict any input from keyboard

查看:376
本文介绍了仅允许从条形码扫描仪输入文本框并限制键盘的任何输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一些功能,文本框只接受来自条形码扫描仪的输入,并限制键盘的任何其他输入。

There is functionality like, the textbox accepts input from only barcode scanner and restricts any other input from keyboard.

推荐答案

关注用于限制键盘的输入..只需尝试连接条形码扫描仪并检查它是否有效..

Following is for restricting input from keyboard .. Just try connecting your barcode scanner and check if it works..

 textBox.onkeypress = function(e) {
       e = e || window.event;
       var charCode = (typeof e.which == "number") ? e.which : e.keyCode;
       if (/\D/.test(String.fromCharCode(charCode))) {
           return false;
       }
    };

LIVE DEMO

对于字母数字

Chk this

LIVE DEMO

这篇关于仅允许从条形码扫描仪输入文本框并限制键盘的任何输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆