Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

166
Visualizações
How to save texts from text box to a variable and showing the variable to append

I'm new to coding and I was wondering how to correct the following code.

Basically, I want to save the user's scanned input to a variable and display it as a prepend. Also If possible being able to scan multiple scans while it just adds it to another variable so I can export the variables. Something like this when its exported as a .txt file

testscan1  
tesstscan2  
ABCDEF

var string = "";
let inputStart, inputStop;

$("#scanInput")[0].onpaste = e => e.preventDefault();
// handle a key value being entered by either keyboard or scanner

var lastInput

let checkValidity = () => {
  if ($("#scanInput").val().length < 8) {
    $("#scanInput").val('');
  } else {
    $("body").append()

  }
  timeout = false
}

let timeout = false

$("#scanInput").keypress(function(e) {
  if (performance.now() - lastInput > 50) {
    $("#scanInput").val('')
  }
  
  lastInput = performance.now();
  
  if (!timeout) {
    timeout = setTimeout(checkValidity, 200)
  }
});
<form autocomplete="off" onsubmit="return false">
  <br> 
  <input type="text" name="serial" placeholder="Please scan laptop Barcode" id="scanInput" />
</form>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda