I have a textbox that shows only numbers
<input type="number" min="0" max="999999999999999999" maxlength="1">
and I have a barcode scanner
now
the thins is that when I type on my keyboard I can only type 1 character and it will show 1 character on the textbox but I am having trouble in the barcode scanner because when I scan on the scanner it only shows 1 character on the text box and I need the whole barcode
can someone please help me on the codes
*note: there should only be one textbox
you've set the maxlength of the input to maxlength="1" - which means that this input can't have more than 1 character - not matter if the source is keyboard or barcode scanner (barcode scanner eventually emulates keyboard input). you need to remove that.
EDIT
as a work around please check this out... what I've done here is measure the time a key stroke takes. measure the time of a keyboard and compare is to the time it take the barcode scanner. if I'm correct then the barcode scanner should be much lower then the keyboard:
<input type="text" onkeydown="checkKeyDown(this)" onkeyup="checkKeyUp(this)" />
<script>
var keyDownTime;
function checkKeyDown(obj) {
keyDownTime = new Date();
};
function checkKeyUp(obj) {
var now = new Date();
alert(now - keyDownTime);
};
</script>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.