var barcode = {
listenerObj: null,
oneKeyTime : '', /* 一次按键时间间隔 */
twoKeyTime : '', /* 两次按键时间间隔 */
keyDownTime: '', /* 键按下的时间 */
barcodeLen : 8 , /* 条形码长度 */
spanTime : 70, /* 一次按键按下到释放的时间间隔 */
on_key_down : function (){
var that = this;
this.listenerObj.keydown(function(e){
if(e.which !== 13 && !(that.in_range(e.which))){
$(that.listenerObj).val('');
return ;
}
var d = new Date();
var curTime = parseInt(d.getTime());
if(that.keyDownTime !== '' && that.keyDownTime !== NaN){
that.twoKeyTime = curTime - that.keyDownTime;
}
that.keyDownTime = curTime;
});
},
on_key_up : function(){
var that = this;
this.listenerObj.keyup(function(e){
var d = new Date();
var keyUpTime = d.getTime();
that.oneKeyTime = parseInt(keyUpTime) - parseInt(that.keyDownTime);
var isHand = that.checkHandInput();
if(isHand && that.in_range(e.which)){
layer.msg('禁止手动输入');
$(that.listenerObj).val("");
}
})
},
on_key_press : function(){
var that = this;
this.listenerObj.keypress(function(e){
if(e.which == 13 && that.check_barcode()){
that.createListEl();
}
});
},
checkHandInput : function(){
if((this.oneKeyTime > this.spanTime) || this.twoKeyTime > this.spanTime){
return true;
}else{
return false;
}
},
}
<input id="barCode" value="" type="text" placeholder="stay focus" style="" name="">
$("#barCode").startListen({
barcodeLen : 10,
letter : true,
number : true,
show : function(code){
layer.msg(code);
}
});
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有