Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

173
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda