fire an event after the barcode reading and to set focus on textbox

坚强是说给别人听的谎言 提交于 2019-12-10 10:45:56

问题


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.

Summary:

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

thanks guys!

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


回答1:


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;
});


来源:https://stackoverflow.com/questions/12095444/fire-an-event-after-the-barcode-reading-and-to-set-focus-on-textbox

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!