I would like to use barcode scanner in my Laravel application. This is an online Point of Sale Application. I know that barcode scanner returns just a string and press Enter But
Yes, there are two ways:
The autofocus attribute
You can use the autofocus
attribute, but this may not be supported by any browser.
Use Javascript
This is a fallback for the autofocus
attribute.
window.onload = function() {
var input = document.getElementById("barcodeInput").focus();
}
This will set the focus as soon as the page is loaded inside the input with the id barcodeInput
.
If you are using JQuery
you can do it this way:
$(document).ready(function() {
$('#barcodeInput').focus();
});