I'm using QuaggaJS for scanning barcodes, the barcode I return in a input field. How can I run a function when Quagga put's a barcode in my input?

Onchange & Oninput

<input oninput="alert_success()" class="form-control" id="bnummer" type="text" name="Bnummer" value="" style="width: 280px" required><br/>

That I can run a function when Quagga puts a barcode in my input field

I've now placed an alert where Quagga detect my barcode, this works fine on my PC but on my smartphone is doesn't work.....

Quagga.onDetected(function(result) {
        var code = result.codeResult.code;

        document.getElementById("bnummer").value = code;


1 Answers

Quentin On Best Solutions

Detecting programmatic changes to a form control's value is usually more trouble then it is worth.

Instead, use the Quagga.onDetected(callback) method (where callback is your function) as described in the documentation.