fire an event after the barcode reading and to set

2019-05-19 01:55发布

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条回答
Deceive 欺骗
2楼-- · 2019-05-19 02:21

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;
});
查看更多
登录 后发表回答