酒吧code阅读后触发一个事件,将焦点设置文本框 [英] fire an event after the barcode reading and to set focus on textbox

查看:198
本文介绍了酒吧code阅读后触发一个事件,将焦点设置文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一个基本的酒吧code Web应用程序的工作。我有两个文本框,所以我需要扫描之一,然后触发事件将焦点设置到另一个(两个文本框的长度是不相等的)。如果两个栏codeS数据库搜索匹配,显示一些标签在数据库中的信息。

I'm working with a basic Barcode Web App. I have two textbox, so I need to scan one, and then fire an event to set the focus to the other one (the length of both textbox are not equal). If the both barcodes matches a dataBase search, display some label with the dataBase information.

摘要:

扫描一个酒吧code,自动设定聚焦到另一个文本框,然后扫描第二条code,终于显示数据库查询的结果。

Scan one barcode, automatically set focus to the other textbox then scan the second barcode, finally display a result of the database lookup.

谢谢你们!

PS。我与VS 2010的工作,asp.net和C#为codebehind。

ps. I'm working with VS 2010, asp.net and C# as codebehind.

推荐答案

使用jQuery(允许只是数字吧code):

Using jQuery (allow just numbers to barcode):

$('#<%=yourFirstTextBox.ClientID %>').keydown(function(e) {
    var code = (e.keyCode ? e.keyCode : e.which);
    if (code == 13) { //Enter keycode
        $('#<%=yourSecondTextBox.ClientID %>').focus()
    }
    else if ((code >= 48 && code <= 57) || (code >= 96 && code <= 105) || (code == 8) || (code >= 37 && code <= 40) || (code == 46))
        return true;
    else
        return false;
});

这篇关于酒吧code阅读后触发一个事件,将焦点设置文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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