title: Detect text filled by barcode scanner(reader) javascript
body: <p>The code checks barcodes using a barcode scanner.
  <code>Search_code</code> is filled by a user (keyboard) , and <code>insert_code</code> is filled automatically by a barcode scanner.
  Currently, code works if both inputs are introduced in barcode scanner values ​​which is not functional for me.</p>
  
  <p>The code needs to run when:</p>
  
  <ol>
  <li><code>search_code</code> is entered manually ( keyboard ) and</li>
  <li><code>insert_code</code> is filled automatically by the barcode scanner </li>
  </ol>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var search_code = document.getElementById('search_code');
  var insert_code = document.getElementById('insert_code');
  var result = document.getElementById('result');
  var button = document.getElementById('button');
  var audio = new Audio('sound.wav');
  
  
  // respond to button click
  button.onclick = function validate(e) {
    e.preventDefault(); 
  
    // show verification result:
    if (search_code.value == insert_code.value) {
      result.textContent = 'code ok';
      result.className = "ok";
      audio.play();
    } else {
      result.textContent = 'code is not ok';
      result.className = "not-ok";
    }
    // clear input when wrong:
    if (search_code.value !== insert_code.value) {
      insert_code.value = '';
    }
    return false;
  };
  
  function clearField(input) {
    input.value = "";
  };</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>....     
  &lt;form&gt;
          &lt;input type="text" name="search_code" onfocus="clearField(this, this.placeholder='');" onblur="this.placeholder='introdu codul'" id="search_code" placeholder="introdu codul" autocomplete="off" value=""/&gt;&lt;br/&gt;
          &lt;input type="" name="insert_code" onfocus="clearField(this, this.placeholder='');" onblur="this.placeholder='scaneaza codul'" id="insert_code" placeholder="scaneaza codul" autocomplete="off" value=""/&gt;&lt;br/&gt;&lt;br/&gt;
          &lt;input type="submit" id="button" name="button" value="verifica COD" /&gt;
      &lt;/form&gt;
  
      &lt;/div&gt;
    &lt;div id="result"&gt;&lt;/div&gt;
     &lt;/div&gt;
     &lt;script src="js/action_input.js"&gt;&lt;/script&gt;
   &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>Thank you!</p>